Skip to content

Commit 4987b47

Browse files
committed
feat: adds xns proto options for specifying defaults
1 parent c041e56 commit 4987b47

23 files changed

Lines changed: 2309 additions & 760 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ The generated code includes resources that are compatible with the Temporal Go S
644644
645645
*__Experimental__*
646646
647-
This plugin provides experimental support for cross-namespace and/or cross-cluster integration by enabling the `enable-xns` plugin option. When enabled, the plugin will generate an additional `path/to/generated/code/<package>xns` go package containing types, methods, and helpers for calling workflows, queries, signals, and updates from other Temporal workflows via activities. The activities use [heartbeating](https://docs.temporal.io/activities#activity-heartbeat) to maintain liveness for long-running workflows or updates, and their associated timeouts can be configured using the generated options helpers. For an example of xns integration, see the [example/external](./example/external/external.go) package.
647+
This plugin provides experimental support for cross-namespace and/or cross-cluster integration by enabling the `enable-xns` plugin option. When enabled, the plugin will generate an additional `path/to/generated/code/<package>xns` go package containing types, methods, and helpers for calling workflows, queries, signals, and updates from other Temporal workflows via activities. The activities use [heartbeating](https://docs.temporal.io/activities#activity-heartbeat) to maintain liveness for long-running workflows or updates, and their associated timeouts can be configured using the generated options helpers. For an example of xns integration, see the [example/external](./example/external) package.
648648
649649
## Documentation
650650

docs/api/temporal/v1/api.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- [WorkflowOptions.Query](#temporal-v1-WorkflowOptions-Query)
1717
- [WorkflowOptions.Signal](#temporal-v1-WorkflowOptions-Signal)
1818
- [WorkflowOptions.Update](#temporal-v1-WorkflowOptions-Update)
19+
- [XNSActivityOptions](#temporal-v1-XNSActivityOptions)
1920

2021
- [CLIFeature](#temporal-v1-CLIFeature)
2122
- [IDReusePolicy](#temporal-v1-IDReusePolicy)
@@ -104,6 +105,7 @@ available query configuration options
104105
| Field | Type | Label | Description |
105106
| ----- | ---- | ----- | ----------- |
106107
| name | [string](#string) | | Fully-qualified query name |
108+
| xns | [XNSActivityOptions](#temporal-v1-XNSActivityOptions) | | XNS can be used to configure default activity options for xns workflow executions |
107109

108110

109111

@@ -156,6 +158,7 @@ available signal configuration options
156158
| Field | Type | Label | Description |
157159
| ----- | ---- | ----- | ----------- |
158160
| name | [string](#string) | | Fully-qualified signal name |
161+
| xns | [XNSActivityOptions](#temporal-v1-XNSActivityOptions) | | XNS can be used to configure default activity options for xns workflow executions |
159162

160163

161164

@@ -175,6 +178,7 @@ available update configuration options
175178
| name | [string](#string) | | Fully-qualified update name |
176179
| validate | [bool](#bool) | | Include validation hook |
177180
| wait_policy | [WaitPolicy](#temporal-v1-WaitPolicy) | | Default wait policy if not specified |
181+
| xns | [XNSActivityOptions](#temporal-v1-XNSActivityOptions) | | XNS can be used to configure default activity options for xns workflow executions |
178182

179183

180184

@@ -205,6 +209,7 @@ available workflow configuration options
205209
| task_queue | [string](#string) | | Override service task queeu |
206210
| task_timeout | [google.protobuf.Duration](#google-protobuf-Duration) | | The timeout for processing workflow task from the time the worker pulled this task. If a workflow task is lost, it is retried after this timeout. The resolution is seconds. |
207211
| wait_for_cancellation | [bool](#bool) | | WaitForCancellation specifies whether to wait for canceled child workflow to be ended (child workflow can be ended as: completed/failed/timedout/terminated/canceled) |
212+
| xns | [XNSActivityOptions](#temporal-v1-XNSActivityOptions) | | XNS can be used to configure default activity options for xns workflow executions |
208213

209214

210215

@@ -220,6 +225,7 @@ Query identifies a query supported by the worklow
220225
| Field | Type | Label | Description |
221226
| ----- | ---- | ----- | ----------- |
222227
| ref | [string](#string) | | Query name |
228+
| xns | [XNSActivityOptions](#temporal-v1-XNSActivityOptions) | | XNS can be used to configure default activity options for xns workflow executions |
223229

224230

225231

@@ -236,6 +242,7 @@ Signal identifies a signal supported by the workflow
236242
| ----- | ---- | ----- | ----------- |
237243
| ref | [string](#string) | | Signal name |
238244
| start | [bool](#bool) | | Include convenience method for signal with start |
245+
| xns | [XNSActivityOptions](#temporal-v1-XNSActivityOptions) | | XNS can be used to configure default activity options for xns workflow executions |
239246

240247

241248

@@ -251,6 +258,29 @@ Update identifies an update supported by the workflow
251258
| Field | Type | Label | Description |
252259
| ----- | ---- | ----- | ----------- |
253260
| ref | [string](#string) | | Update name |
261+
| xns | [XNSActivityOptions](#temporal-v1-XNSActivityOptions) | | XNS can be used to configure default activity options for xns workflow executions |
262+
263+
264+
265+
266+
267+
268+
<a name="temporal-v1-XNSActivityOptions"></a>
269+
270+
### XNSActivityOptions
271+
272+
273+
274+
| Field | Type | Label | Description |
275+
| ----- | ---- | ----- | ----------- |
276+
| name | [string](#string) | | Fully-qualified xns activity name |
277+
| task_queue | [string](#string) | | Override default task queue for activity |
278+
| schedule_to_close_timeout | [google.protobuf.Duration](#google-protobuf-Duration) | | Total time that a workflow is willing to wait for Activity to complete |
279+
| schedule_to_start_timeout | [google.protobuf.Duration](#google-protobuf-Duration) | | Time that the Activity Task can stay in the Task Queue before it is picked up by a Worker |
280+
| start_to_close_timeout | [google.protobuf.Duration](#google-protobuf-Duration) | | Maximum time of a single Activity execution attempt |
281+
| heartbeat_interval | [google.protobuf.Duration](#google-protobuf-Duration) | | HeartbeatInterval configures the default heartbeat interval |
282+
| heartbeat_timeout | [google.protobuf.Duration](#google-protobuf-Duration) | | Heartbeat timeout. Activity must call Activity.RecordHeartbeat(ctx, &#34;my-heartbeat&#34;) |
283+
| retry_policy | [RetryPolicy](#temporal-v1-RetryPolicy) | | Specifies how to retry an Activity if an error occurs |
254284

255285

256286

docs/api/temporal/xns/v1/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ QueryRequest can be used to configure xns query activities
3838
| run_id | [string](#string) | | |
3939
| workflow_id | [string](#string) | | |
4040
| request | [google.protobuf.Any](#google-protobuf-Any) | | |
41+
| heartbeat_interval | [google.protobuf.Duration](#google-protobuf-Duration) | | |
4142

4243

4344

@@ -74,6 +75,7 @@ SignalRequest can be used to configure xns signal activities
7475
| run_id | [string](#string) | | |
7576
| workflow_id | [string](#string) | | |
7677
| request | [google.protobuf.Any](#google-protobuf-Any) | | |
78+
| heartbeat_interval | [google.protobuf.Duration](#google-protobuf-Duration) | | |
7779

7880

7981

example/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# example protoc-gen-go-temporal usage
2+
3+
In an initial terminal:
4+
1. Start temporal
5+
```shell
6+
temporal server start-dev --dynamic-config-value "frontend.enableUpdateWorkflowExecution=true"
7+
```
8+
9+
In a second terminal:
10+
2. Create search attributes in default namespace
11+
```shell
12+
temporal operator search-attribute create --name foo --type Text
13+
temporal operator search-attribute create --name created_at --type Datetime
14+
```
15+
3. Create `external` namespace
16+
```shell
17+
temporal operator namespace create external
18+
temporal operator search-attribute create --namespace external --name foo --type Text
19+
temporal operator search-attribute create --namespace external --name created_at --type Datetime
20+
```
21+
3. Run `example` worker
22+
```shell
23+
go run example/main.go worker
24+
```
25+
26+
In a third terminal:
27+
1. Run `external` worker
28+
```shell
29+
go run example/main.go external worker
30+
```
31+
32+
In a fourth terminal:
33+
1. Execute a workflow
34+
```shell
35+
go run example/main.go external provision-foo --request-name test
36+
```

example/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,3 @@ func main() {
162162
log.Fatal(err)
163163
}
164164
}
165-
166-
// ============================================================================

example/proto/example/v1/example.proto

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ service Example {
1717
execution_timeout: { seconds: 3600 }
1818
id_reuse_policy: WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE
1919
id: 'create-foo/${! name.slug() }'
20-
// search_attributes:
21-
// 'foo = name\n'
22-
// 'created_at = now().ts_tz("UTC")\n'
20+
xns: {
21+
heartbeat_interval: { seconds: 10 }
22+
heartbeat_timeout: { seconds: 20 }
23+
start_to_close_timeout: { seconds: 3630 }
24+
}
25+
search_attributes:
26+
'foo = name\n'
27+
'created_at = now().ts_tz("UTC")\n'
2328
query: { ref: 'GetFooProgress' }
2429
signal: { ref: 'SetFooProgress', start: true }
2530
update: { ref: 'UpdateFooProgress' }
@@ -28,7 +33,13 @@ service Example {
2833

2934
// GetFooProgress returns the status of a CreateFoo operation
3035
rpc GetFooProgress(google.protobuf.Empty) returns (GetFooProgressResponse) {
31-
option (temporal.v1.query) = {};
36+
option (temporal.v1.query) = {
37+
xns: {
38+
heartbeat_interval: { seconds: 10 }
39+
heartbeat_timeout: { seconds: 20 }
40+
start_to_close_timeout: { seconds: 60 }
41+
}
42+
};
3243
}
3344

3445
// Notify sends a notification
@@ -43,13 +54,24 @@ service Example {
4354

4455
// SetFooProgress sets the current status of a CreateFoo operation
4556
rpc SetFooProgress(SetFooProgressRequest) returns (google.protobuf.Empty) {
46-
option (temporal.v1.signal) = {};
57+
option (temporal.v1.signal) = {
58+
xns: {
59+
heartbeat_interval: { seconds: 10 }
60+
heartbeat_timeout: { seconds: 20 }
61+
start_to_close_timeout: { seconds: 60 }
62+
}
63+
};
4764
}
4865

4966
// UpdateFooProgress sets the current status of a CreateFoo operation
5067
rpc UpdateFooProgress(SetFooProgressRequest) returns (GetFooProgressResponse) {
5168
option (temporal.v1.update) = {
5269
id: 'update-progress/${! progress.string() }',
70+
xns: {
71+
heartbeat_interval: { seconds: 10 }
72+
heartbeat_timeout: { seconds: 20 }
73+
start_to_close_timeout: { seconds: 60 }
74+
}
5375
};
5476
}
5577
}

0 commit comments

Comments
 (0)