Skip to content

Commit e1fe251

Browse files
committed
change some structure
1 parent 1fbe712 commit e1fe251

File tree

1 file changed

+49
-34
lines changed

1 file changed

+49
-34
lines changed

cmd/samples/recipes/versioning/README.md

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ This example demonstrates a safe deployment strategy that allows you to:
4747
3. **Rollback safely** if issues are discovered
4848
4. **Gradually migrate** workflows to new versions
4949

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 |
60+
|------------|-----------|-----------|-----------|-----------|
61+
| V1 |||||
62+
| V2 |||||
63+
| V3 |||||
64+
| V4 |||||
65+
5066
## Running the Example
5167

5268
### Prerequisites
@@ -65,83 +81,82 @@ go build -o bin/versioning cmd/samples/recipes/versioning/*.go
6581
./bin/versioning -m worker -v 1
6682
```
6783

68-
#### 2. Trigger a Workflow (Executed by Worker V1)
84+
#### 2. Trigger a Workflow
6985
```bash
7086
./bin/versioning -m trigger
7187
```
7288

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:
7493

75-
#### 3. Deploy Worker V2 (Safe Deployment)
7694
```bash
7795
./bin/versioning -m worker -v 2
7896
```
7997

98+
The workflow should still be executed by worker V1.
99+
80100
#### 4. Test V2 Compatibility
101+
Let's simulate that worker V1 is shut down and the workflow will be rescheduled to the V2 worker:
81102
* 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.
83105

84106
#### 5. Upgrade to Version V3
107+
Let's continue the deployment and upgrade to V3, running a V3 worker alongside the V2 worker:
108+
85109
```bash
86110
./bin/versioning -m worker -v 3
87111
```
88112

113+
The workflow should still be executed by worker V2.
114+
89115
#### 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+
90118
* 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.
92119

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.
97121

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:
99124

100-
#### 8. Gracefully Stop the Workflow
101125
```bash
102126
./bin/versioning -m stop
103127
```
104128

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+
106134
```bash
107135
./bin/versioning -m trigger
108136
```
109137

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:
111142

112-
#### 10. Rollback to Worker V2
113143
```bash
114144
./bin/versioning -m worker -v 2
115145
```
116146

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.
119149

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:
122152

123153
```bash
124154
./bin/versioning -m worker -v 4
125155
```
126156

127157
* 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.
131159

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 |
140-
|------------|-----------|-----------|-----------|-----------|
141-
| V1 |||||
142-
| V2 |||||
143-
| V3 |||||
144-
| V4 |||||
145160

146161
## Command Reference
147162

0 commit comments

Comments
 (0)