Skip to content

Worker Deployment Versioning #1679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
May 16, 2025
Merged

Worker Deployment Versioning #1679

merged 22 commits into from
May 16, 2025

Conversation

Sushisource
Copy link
Member

What was changed

Added the annotations and options for worker-deployment-based versioning

Why?

All aboard the versioning train

Checklist

  1. Closes [Feature Request] Support New Worker Versioning API #1659

  2. How was this tested:
    Added tests

  3. Any docs updates needed?

@Sushisource Sushisource requested a review from a team as a code owner April 15, 2025 23:58
Copy link
Contributor

@THardy98 THardy98 left a comment

Choose a reason for hiding this comment

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

Didn't really look through the core bridge stuff, maybe worth coordinating on #1638.

For your workflow test files deployment-versioning-no-annotations... there's a workflows directory in test/src that might make more sense for them to be located, instead of directly in test/src.

Just want to re-affirm how this works:

  • on the worker, we have the worker's configured deployment version, and the default versioning behaviour for all its workflows
  • on the workflow, we can override this versioning behaviour with the newly added workflow definition options (it's a little funky, we're making use of JS's quirk that a function is an object, so a workflow with definition options is a function with properties, as already discussed)
  • workflow versioning behaviour is read into the activator (which uses it solely when concluding the activation) and workflow info

Tests were helpful, though I think you probably want someone whose more familiar with the versioning behaviour to take a look

@Sushisource Sushisource force-pushed the worker-deployment-versioning branch 4 times, most recently from a120422 to e59e2d0 Compare April 18, 2025 23:33
@Sushisource Sushisource force-pushed the worker-deployment-versioning branch from a8d4a69 to f18b1ca Compare April 24, 2025 00:00
@Sushisource
Copy link
Member Author

This will need to hang out for a bit since I want temporalio/api#579 in before I incorporate that

@Sushisource Sushisource force-pushed the worker-deployment-versioning branch 2 times, most recently from 218743e to 8169797 Compare May 2, 2025 01:06
@Sushisource Sushisource force-pushed the worker-deployment-versioning branch 4 times, most recently from e79e306 to 3ee553e Compare May 9, 2025 21:27
/**
* A workflow function that has been defined with options from {@link WorkflowDefinitionOptions}.
*/
export interface WorkflowFunctionWithOptions<Args extends any[], ReturnType> extends AsyncFunction<Args, ReturnType> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this have any value being exported publicly? If yes, then AsyncFunction should also be exported. If not, then please add @internal and @hidden (I will have to experiment a bit more to figure out how to reduce this to a single annotation, but in the mean time, let's use both).

@Sushisource Sushisource force-pushed the worker-deployment-versioning branch from 0382bdf to 48bbb74 Compare May 14, 2025 22:05
@Sushisource Sushisource force-pushed the worker-deployment-versioning branch 2 times, most recently from 4c67a37 to ee0f8ed Compare May 15, 2025 17:07
@Sushisource Sushisource force-pushed the worker-deployment-versioning branch from ee0f8ed to 129ab88 Compare May 15, 2025 17:16
@Sushisource Sushisource force-pushed the worker-deployment-versioning branch from 9209367 to f60c0a0 Compare May 15, 2025 21:52
@@ -1227,6 +1227,7 @@ export class WorkflowClient extends BaseClient {
cronSchedule: options.cronSchedule,
header: { fields: headers },
priority: options.priority ? compilePriority(options.priority) : undefined,
versioningOverride: options.versioningOverride ? options.versioningOverride : undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
versioningOverride: options.versioningOverride ? options.versioningOverride : undefined,
versioningOverride: options.versioningOverride ?? undefined,

@@ -1296,6 +1297,7 @@ export class WorkflowClient extends BaseClient {
cronSchedule: opts.cronSchedule,
header: { fields: headers },
priority: opts.priority ? compilePriority(opts.priority) : undefined,
versioningOverride: opts.versioningOverride ? opts.versioningOverride : undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
versioningOverride: opts.versioningOverride ? opts.versioningOverride : undefined,
versioningOverride: opts.versioningOverride ?? undefined,

@@ -80,9 +80,27 @@ export function initRuntime(options: WorkflowCreateOptionsInternal): void {
const defaultWorkflowFn = mod['default'];

if (typeof workflowFn === 'function') {
activator.workflow = workflowFn;
if (isWorkflowFunctionWithOptions(workflowFn)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like those two branches are identical, and in both branches, you ned up making the assignment to activator.workflow anyway. I'd suggest reverting to the original if-elseif-else structure, and move the "workflow definition options" stuff after that whole block.

Copy link
Contributor

@mjameswh mjameswh left a comment

Choose a reason for hiding this comment

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

Still a few nits, but no need for another round of review after that. You can safely ignore the unrelated test failures on the feature repo due to protobufjs, as well as the doc publish error due to vercel token needing refresh.

@Sushisource Sushisource force-pushed the worker-deployment-versioning branch from fd9e99c to bc6157f Compare May 16, 2025 16:24
@Sushisource Sushisource merged commit 9aae0d2 into main May 16, 2025
25 of 27 checks passed
@Sushisource Sushisource deleted the worker-deployment-versioning branch May 16, 2025 16:42
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.

[Feature Request] Support New Worker Versioning API
5 participants