You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cmd/samples/recipes/versioning/README.md
+49-34Lines changed: 49 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,6 +47,22 @@ This example demonstrates a safe deployment strategy that allows you to:
47
47
3.**Rollback safely** if issues are discovered
48
48
4.**Gradually migrate** workflows to new versions
49
49
50
+
51
+
## Important Notes
52
+
53
+
-**Single Workflow Limitation**: This sample allows only one workflow at a time to simplify the signal handling mechanism. In production, you would typically handle multiple workflows.
54
+
-**Signal Method**: The workflow uses a simple signal method to stop gracefully, keeping the implementation straightforward.
55
+
-**Breaking Changes**: V4 demonstrates what happens when you introduce a breaking change - workflows started by V1 cannot be executed.
56
+
57
+
## Version Compatibility Matrix
58
+
59
+
| Started By | V1 Worker | V2 Worker | V3 Worker | V4 Worker |
@@ -65,83 +81,82 @@ go build -o bin/versioning cmd/samples/recipes/versioning/*.go
65
81
./bin/versioning -m worker -v 1
66
82
```
67
83
68
-
#### 2. Trigger a Workflow (Executed by Worker V1)
84
+
#### 2. Trigger a Workflow
69
85
```bash
70
86
./bin/versioning -m trigger
71
87
```
72
88
73
-
**Deployment started** - You now have a workflow running on V1.
89
+
Wait for logs in the V1 worker to ensure that a workflow has been executed by worker V1.
90
+
91
+
#### 3. Deploy Worker V2
92
+
Let's simulate a deployment from V1 to V2 and run a V2 worker alongside the V1 worker:
74
93
75
-
#### 3. Deploy Worker V2 (Safe Deployment)
76
94
```bash
77
95
./bin/versioning -m worker -v 2
78
96
```
79
97
98
+
The workflow should still be executed by worker V1.
99
+
80
100
#### 4. Test V2 Compatibility
101
+
Let's simulate that worker V1 is shut down and the workflow will be rescheduled to the V2 worker:
81
102
* Kill the process of worker V1 (Ctrl+C), then wait 5 seconds to see workflow rescheduling to worker V2 without errors.
82
-
* Verify logs of V2, V2 should handle workflows started by V1.
103
+
104
+
Verify logs of the V2 worker - it should handle the workflow started by V1.
83
105
84
106
#### 5. Upgrade to Version V3
107
+
Let's continue the deployment and upgrade to V3, running a V3 worker alongside the V2 worker:
108
+
85
109
```bash
86
110
./bin/versioning -m worker -v 3
87
111
```
88
112
113
+
The workflow should still be executed by worker V2.
114
+
89
115
#### 6. Test V3 Compatibility
116
+
Let's simulate that worker V2 is shut down and the workflow will be rescheduled to the V3 worker:
117
+
90
118
* Kill the process of worker V2, then wait 5 seconds to see workflow rescheduling to worker V3 without errors.
91
-
* Verify logs of V3 worker, V3 worker should handle workflows started by V1.
92
119
93
-
#### 7. Test Breaking Change with V4
94
-
```bash
95
-
./bin/versioning -m worker -v 4
96
-
```
120
+
Verify logs of the V3 worker - it should handle the workflow started by V2.
97
121
98
-
Kill the process of worker V3. You'll notice that workflows initiated by V1 cannot be executed by version V4 - this simulates a breaking change.
122
+
#### 7. Gracefully Stop the Workflow
123
+
Before upgrading to V4, we should ensure that the workflow has been stopped, otherwise it will fail. For this, we need to send a signal to stop it gracefully:
99
124
100
-
#### 8. Gracefully Stop the Workflow
101
125
```bash
102
126
./bin/versioning -m stop
103
127
```
104
128
105
-
#### 9. Start a New Workflow (Will Use V4 Logic)
129
+
You should see that the workflow has been stopped.
130
+
131
+
#### 8. Start a New Workflow
132
+
Let's start a new workflow:
133
+
106
134
```bash
107
135
./bin/versioning -m trigger
108
136
```
109
137
110
-
The workflow will use version 1 of the change ID (V4's default).
138
+
The workflow will use version 1 of the change ID (V3's and V4's default).
139
+
140
+
#### 9. Rollback to Worker V2
141
+
Let's imagine that V3 has an issue and we need to rollback to V2. Let's start a worker V2:
111
142
112
-
#### 10. Rollback to Worker V2
113
143
```bash
114
144
./bin/versioning -m worker -v 2
115
145
```
116
146
117
-
* Kill the process of worker V4, then wait for workflow rescheduling.
118
-
* Verify logs of V2 worker, V2 worker should handle workflows started by V4.
147
+
* Kill the process of worker V3, then wait for workflow rescheduling.
148
+
* Verify logs of V2 worker - V2 worker should handle workflows started by V3.
119
149
120
-
#### 11. Aggressive Upgrade: V2 to V4 (Breaking Change)
121
-
Since V3 worked fine, we decide to combine getting rid of support for V1 and make an upgrade straightforward to V4:
150
+
#### 10. Aggressive Upgrade: V2 to V4 (Breaking Change)
151
+
We decide to combine getting rid of support for V1 and make an upgrade straightforward to V4:
122
152
123
153
```bash
124
154
./bin/versioning -m worker -v 4
125
155
```
126
156
127
157
* Kill the process of worker V2, then wait for workflow rescheduling.
128
-
* Verify logs of V4 worker, V4 worker should handle workflows started by V4.
129
-
130
-
## Important Notes
158
+
* Verify logs of V4 worker - V4 worker should handle workflows started by V4.
131
159
132
-
-**Single Workflow Limitation**: This sample allows only one workflow at a time to simplify the signal handling mechanism. In production, you would typically handle multiple workflows.
133
-
-**Signal Method**: The workflow uses a simple signal method to stop gracefully, keeping the implementation straightforward.
134
-
-**Version Compatibility**: Each version is designed to handle workflows started by compatible previous versions.
135
-
-**Breaking Changes**: V4 demonstrates what happens when you introduce a breaking change - workflows started by V1 cannot be executed.
136
-
137
-
## Version Compatibility Matrix
138
-
139
-
| Started By | V1 Worker | V2 Worker | V3 Worker | V4 Worker |
0 commit comments