-
Notifications
You must be signed in to change notification settings - Fork 126
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
Changes from all commits
82728d4
575ce16
3cf3721
fd446be
f5bf58d
51332f9
0af2b2a
46276ad
eec433b
84acea6
04368ae
3609847
9ebf04b
d3ebdd7
dadeec0
77e6d3f
d6074f0
fe53f54
77cd10e
129ab88
f60c0a0
bc6157f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import type { temporal } from '@temporalio/proto'; | ||
import { makeProtoEnumConverters } from './internal-workflow'; | ||
|
||
/** | ||
* Represents the version of a specific worker deployment. | ||
* | ||
* @experimental Deployment based versioning is experimental and may change in the future. | ||
*/ | ||
export interface WorkerDeploymentVersion { | ||
readonly buildId: string; | ||
readonly deploymentName: string; | ||
} | ||
|
||
/** | ||
* @returns The canonical representation of a deployment version, which is a string in the format | ||
* `deploymentName.buildId`. | ||
*/ | ||
export function toCanonicalString(version: WorkerDeploymentVersion): string { | ||
return `${version.deploymentName}.${version.buildId}`; | ||
} | ||
|
||
/** | ||
* Specifies when a workflow might move from a worker of one Build Id to another. | ||
* | ||
* * 'PINNED' - The workflow will be pinned to the current Build ID unless manually moved. | ||
* * 'AUTO_UPGRADE' - The workflow will automatically move to the latest version (default Build ID | ||
* of the task queue) when the next task is dispatched. | ||
THardy98 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
* @experimental Deployment based versioning is experimental and may change in the future. | ||
*/ | ||
export const VersioningBehavior = { | ||
PINNED: 'PINNED', | ||
AUTO_UPGRADE: 'AUTO_UPGRADE', | ||
} as const; | ||
export type VersioningBehavior = (typeof VersioningBehavior)[keyof typeof VersioningBehavior]; | ||
|
||
export const [encodeVersioningBehavior, decodeVersioningBehavior] = makeProtoEnumConverters< | ||
temporal.api.enums.v1.VersioningBehavior, | ||
typeof temporal.api.enums.v1.VersioningBehavior, | ||
keyof typeof temporal.api.enums.v1.VersioningBehavior, | ||
typeof VersioningBehavior, | ||
'VERSIONING_BEHAVIOR_' | ||
>( | ||
{ | ||
[VersioningBehavior.PINNED]: 1, | ||
[VersioningBehavior.AUTO_UPGRADE]: 2, | ||
UNSPECIFIED: 0, | ||
} as const, | ||
'VERSIONING_BEHAVIOR_' | ||
); | ||
|
||
/** | ||
* Represents versioning overrides. For example, when starting workflows. | ||
*/ | ||
export type VersioningOverride = PinnedVersioningOverride | 'AUTO_UPGRADE'; | ||
|
||
/** | ||
* Workflow will be pinned to a specific deployment version. | ||
*/ | ||
export interface PinnedVersioningOverride { | ||
/** | ||
* The worker deployment version to pin the workflow to. | ||
*/ | ||
pinnedTo: WorkerDeploymentVersion; | ||
} | ||
|
||
/** | ||
* The workflow will auto-upgrade to the current deployment version on the next workflow task. | ||
*/ | ||
export type AutoUpgradeVersioningOverride = 'AUTO_UPGRADE'; |
THardy98 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { VersioningBehavior } from './worker-deployments'; | ||
|
||
/** | ||
* Options that can be used when defining a workflow via {@link setWorkflowOptions}. | ||
*/ | ||
export interface WorkflowDefinitionOptions { | ||
versioningBehavior?: VersioningBehavior; | ||
} | ||
|
||
type AsyncFunction<Args extends any[], ReturnType> = (...args: Args) => Promise<ReturnType>; | ||
export type WorkflowDefinitionOptionsOrGetter = WorkflowDefinitionOptions | (() => WorkflowDefinitionOptions); | ||
|
||
/** | ||
* @internal | ||
* @hidden | ||
* A workflow function that has been defined with options from {@link WorkflowDefinitionOptions}. | ||
*/ | ||
export interface WorkflowFunctionWithOptions<Args extends any[], ReturnType> extends AsyncFunction<Args, ReturnType> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this have any value being exported publicly? If yes, then |
||
workflowDefinitionOptions: WorkflowDefinitionOptionsOrGetter; | ||
} |
Uh oh!
There was an error while loading. Please reload this page.