Skip to content

Commit eaac5f2

Browse files
committed
feat: adds workflow aliasing support
1 parent 9d5c270 commit eaac5f2

File tree

24 files changed

+564
-417
lines changed

24 files changed

+564
-417
lines changed

docs/docs/configuration/workflow.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ service Example {
2828

2929
## Options
3030

31+
### aliases
32+
33+
`repeated string`
34+
35+
List of additional names to register the workflow under. This can be used to migrate to new naming conventions without breaking workflow history or existing clients. See the [guide](/docs/guides/workflows#aliases) for more details.
36+
37+
```protobuf
38+
service Example {
39+
rpc Hello(HelloInput) returns (HelloOutput) {
40+
option (temporal.v1.workflow) = {
41+
aliases: ["example.v1.Hello"] // workers will register the workflow implementation under both names
42+
name: "hello-workflow" // generated clients will use this when executing workflows
43+
};
44+
}
45+
}
46+
```
47+
3148
### execution_timeout
3249

3350
[google.protobuf.Duration](https://protobuf.dev/reference/protobuf/google.protobuf/#duration)

docs/docs/guides/workflows.mdx

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,82 @@ service Example {
363363
</TabItem>
364364
</Tabs>
365365

366+
### Aliases
367+
368+
Workflows can be annotated with 0 or more [aliases](/docs/configuration/workflow#aliases) which results in the worker registering the workflow definition multiple times with different names. This can be used to evolve workflow naming conventions in a non-breaking fashion:
369+
370+
1. Initial workflow definition
371+
372+
```protobuf
373+
syntax="proto3";
374+
375+
package example.v1;
376+
377+
service Example {
378+
rpc Hello(HelloInput) returns (HelloOutput) {
379+
option (temporal.v1.workflow) = {
380+
name: "hello-workflow"
381+
};
382+
}
383+
}
384+
```
385+
386+
2. Add new workflow name as alias.
387+
388+
Old clients and new clients generated from this schema will continue to use the old name when executing workflows. New worker deployments will register the workflow under both names. This step is necessary to prevent new clients from attempting to execute the workflow using the new name before workers have been deployed. If this risk is deemed acceptable, this step can be skipped.
389+
390+
```protobuf
391+
syntax="proto3";
392+
393+
package example.v1;
394+
395+
service Example {
396+
rpc Hello(HelloInput) returns (HelloOutput) {
397+
option (temporal.v1.workflow) = {
398+
name: "hello-workflow"
399+
aliases: ["example.v1.Hello"]
400+
};
401+
}
402+
}
403+
```
404+
405+
3. Update name and aliases.
406+
407+
All new clients will now use the new workflow name. Workers will continue to handle both names.
408+
409+
```protobuf
410+
syntax="proto3";
411+
412+
package example.v1;
413+
414+
service Example {
415+
rpc Hello(HelloInput) returns (HelloOutput) {
416+
option (temporal.v1.workflow) = {
417+
name: "example.v1.Hello"
418+
aliases: ["hello-workflow"]
419+
};
420+
}
421+
}
422+
```
423+
424+
4. Remove old aliases.
425+
426+
Once all old clients have been phased out and old workflow histories have expired, the old alias can be safely removed.
427+
428+
```protobuf
429+
syntax="proto3";
430+
431+
package example.v1;
432+
433+
service Example {
434+
rpc Hello(HelloInput) returns (HelloOutput) {
435+
option (temporal.v1.workflow) = {
436+
name: "example.v1.Hello"
437+
};
438+
}
439+
}
440+
```
441+
366442
## Initializers
367443

368444
Workflow structs can implement an optional `Initialize` method which will be invoked prior to signal channel initialization and query or update handler registrations. This can be useful if a workflow requires the use of an activity to initialize local workflow state.
@@ -766,4 +842,3 @@ service Example {
766842
```
767843
</TabItem>
768844
</Tabs>
769-

gen/example/helloworld/v1/helloworld_temporal.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/example/helloworld/v1/helloworldv1xns/helloworld_xns_temporal.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/example/mutex/v1/mutex_temporal.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/example/mutex/v1/mutexv1xns/mutex_xns_temporal.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/example/searchattributes/v1/searchattributes_temporal.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/example/searchattributes/v1/searchattributesv1xns/searchattributes_xns_temporal.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/example/updatabletimer/v1/updatabletimer_temporal.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/example/updatabletimer/v1/updatabletimerv1xns/updatabletimer_xns_temporal.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)