Skip to content

Add Worker Deployment Versioning sample#48

Merged
Sushisource merged 5 commits intomainfrom
worker-versioning
Sep 19, 2025
Merged

Add Worker Deployment Versioning sample#48
Sushisource merged 5 commits intomainfrom
worker-versioning

Conversation

@Sushisource
Copy link
Copy Markdown
Member

What was changed

Updating (adding, here) versioning samples in all langauges

Why?

Checklist

  1. Closes

  2. How was this tested:

  1. Any docs updates needed?

@Sushisource Sushisource requested a review from a team as a code owner September 17, 2025 01:25
Comment thread worker_versioning/activities.rb Outdated
Comment on lines +5 to +6
module WorkerVersioning
class SomeActivity < Temporalio::Activity::Definition
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
module WorkerVersioning
class SomeActivity < Temporalio::Activity::Definition
module WorkerVersioning
module Activities
class SomeActivity < Temporalio::Activity::Definition

These should be in a module called Activities if they are in a non-main file with that name IMO

Comment thread worker_versioning/constants.rb Outdated
Comment on lines +4 to +5
TASK_QUEUE = 'worker-versioning'
DEPLOYMENT_NAME = 'my-deployment'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TASK_QUEUE = 'worker-versioning'
DEPLOYMENT_NAME = 'my-deployment'
module Constants
TASK_QUEUE = 'worker-versioning'
DEPLOYMENT_NAME = 'my-deployment'
end

Not really required, but clearer IMO

Comment thread worker_versioning/app.rb Outdated
client = Temporalio::Client.connect(
'localhost:7233',
'default',
logger: logger
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger: logger
logger:

Pedantic, but don't need to provide variable if named the same as the kw arg

Comment thread worker_versioning/app.rb Outdated
# them, we're demonstrating that the client remains version-agnostic.
auto_upgrade_workflow_id = "worker-versioning-versioning-autoupgrade_#{SecureRandom.uuid}"
auto_upgrade_execution = client.start_workflow(
'AutoUpgrading',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'AutoUpgrading',
:AutoUpgrading,

I think you can use a symbol here (but if not, we need to fix it) and for other workflows you reference by name if you don't want to actually reference a class

Comment thread worker_versioning/app.rb Outdated
# Now we'll conclude all workflows. You should be able to see in your server UI that the pinned
# workflow always stayed on 1.0, while the auto-upgrading workflow migrated.
[auto_upgrade_execution, pinned_execution, pinned_execution_v2].each do |handle|
handle.signal('do_next_signal', 'conclude')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
handle.signal('do_next_signal', 'conclude')
handle.signal(:do_next_signal, 'conclude')

Pedantic, but also for signal names a symbol makes more sense (or let me know if it doesn't work)

Comment thread worker_versioning/workerv1.rb Outdated
Comment on lines +39 to +41
rescue StandardError => e
logger.error("Worker failed: #{e}")
raise
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rescue StandardError => e
logger.error("Worker failed: #{e}")
raise

Can probably leave this off IMO (other samples do)

require 'temporalio/workflow/definition'
require_relative 'activities'

module WorkerVersioning
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
module WorkerVersioning
module WorkerVersioning
module Workflows

For clarity IMO

Comment thread worker_versioning/workflows.rb Outdated
end

def execute
Temporalio::Workflow.logger.info('Changing workflow v1 started.')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very pedantic, but trailing punctuation a bit inconsistent here

Comment thread worker_versioning/workflows.rb Outdated
workflow_versioning_behavior Temporalio::VersioningBehavior::AUTO_UPGRADE

def initialize
@signals = []
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to change anything, but if you'd like, you can remove this, change the signal method to (@signals ||= []) << signal and change wait condition to Temporalio::Workflow.wait_condition { @signals&.any? }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep it as is. More obvious to me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we don't in other SDKs' samples (and it has bitten us), but in Ruby samples we're trying to have a test for every sample so it doesn't start breaking without us knowing. Even basic tests to make sure the workflows work is ideal, though this can be an opportunity to show how to test versioning if we want to.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added one (same as what I did in .net)

Copy link
Copy Markdown
Contributor

@cretz cretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Small, non-blocking suggestion on the not-found except clause

@Sushisource Sushisource merged commit 794f0b8 into main Sep 19, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants