This repository demonstrates how to use Temporal's Worker Versioning feature in Go. It shows how to safely make breaking changes to your workflows without causing non-determinism errors.
- Go 1.21 or later
- Temporal Server v1.27.1+
- Temporal CLI v1.3.0+
- Temporal UI v2.36.0+
- Start the Temporal server with versioning enabled:
temporal server start-dev \
--dynamic-config-value frontend.workerVersioningWorkflowAPIs=true \
--dynamic-config-value system.enableDeploymentVersions=true
- Verify the server is running:
temporal operator cluster health
.
├── README.md
├── version1/
│ ├── main.go
│ ├── workflow/
│ │ └── workflow.go
│ └── worker/
│ └── worker.go
└── version2/
├── main.go
├── workflow/
│ └── workflow.go
├── activity/
│ └── activity.go
└── worker/
└── worker.go
- First, download dependencies:
go mod tidy
- Run version 1:
go run version1/main.go
This will start a worker and execute a workflow using version 1 of the code.
- Run version 2:
go run version2/main.go
This will start a worker with the updated workflow code and demonstrate how to handle versioning.
At this point two workflows will have been created but neither will actually be processed. We need to create a deployment version
temporal worker deployment list
To make a specific version active for polling:
temporal worker deployment set-current-version --version="demo.1.0"
At this point you should see your first workflow run and complete
temporal worker deployment describe-version -v demo.1.0
You will notice the second workflow is not doing anything. We need to bump the deployment version
temporal worker deployment set-current-version --version="demo.2.0"
temporal worker deployment describe-version -v demo.2.0