Skip to content

bitovi/temporal-versioning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Temporal Worker Versioning Demo

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.

Prerequisites

  • Go 1.21 or later
  • Temporal Server v1.27.1+
  • Temporal CLI v1.3.0+
  • Temporal UI v2.36.0+

Setting Up Temporal Server

  1. Start the Temporal server with versioning enabled:
temporal server start-dev \
  --dynamic-config-value frontend.workerVersioningWorkflowAPIs=true \
  --dynamic-config-value system.enableDeploymentVersions=true
  1. Verify the server is running:
temporal operator cluster health

Project Structure

.
├── README.md
├── version1/
│   ├── main.go
│   ├── workflow/
│   │   └── workflow.go
│   └── worker/
│       └── worker.go
└── version2/
    ├── main.go
    ├── workflow/
    │   └── workflow.go
    ├── activity/
    │   └── activity.go
    └── worker/
        └── worker.go

How to Run

  1. First, download dependencies:
go mod tidy
  1. Run version 1:
go run version1/main.go

This will start a worker and execute a workflow using version 1 of the code.

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

Managing Worker Versions

View Available Versions

temporal worker deployment list

Set Active Version

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

Check Version Status

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

Set new Active Version

temporal worker deployment set-current-version --version="demo.2.0"

Check Version Status

temporal worker deployment describe-version -v demo.2.0

About

Temporal Worker Versioning

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages