-
Notifications
You must be signed in to change notification settings - Fork 53
New Worker Versioning API #645
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
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
00dad7f
feat: add VersioningBehavior enum to manage workflow versioning
roxblnfk cd0f0d9
refactor(tests): update Acceptance Tests Worker constructor to accept…
roxblnfk b763c12
chore: update Temporal Dev to ^1.4.1
roxblnfk 53b64c0
feat: add WorkerDeploymentOptions class for configuring Worker Versio…
roxblnfk cac036d
style(php-cs-fixer): fix coding standards
52227b0
test(acceptance): reorganize versioning tests
roxblnfk 95f26cc
test(acceptance): add Deployment Versioning test
roxblnfk fe7ebd6
feat: introduce WorkflowVersioningBehavior attribute and enhance work…
roxblnfk 96dde24
refactor: update WorkerDeploymentOptions to use WorkerDeploymentVersi…
roxblnfk 5cc27a3
test(acceptance): add Versioning test with Pinned behavior
roxblnfk 09c3a8f
refactor: move VersioningBehavior to Common namespace
roxblnfk d14d66c
feat(WorkflowClient): add VersioningOverride feature;
roxblnfk d517b1a
chore: add phpdoc annotations
roxblnfk 5f0dc26
chore: update RoadRunner version references to 2025.1.3
roxblnfk bca65f2
test: enhance versioning tests
roxblnfk c3f657b
refactor(Process): streamline context handling and initialization logic
roxblnfk e9b4f37
Merge branch 'refs/heads/master' into deployments
roxblnfk dfa10bb
chore: update psalm baseline and composer.json
roxblnfk 0bb56a8
test(Deployment): refactor
roxblnfk 9497fff
test(Acceptance): Sleep after Temporal restart
roxblnfk acdfa85
chore: Fix comments after review
roxblnfk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Temporal\Common\Versioning; | ||
|
|
||
| /** | ||
| * Specifies when a workflow might move from a worker of one Build Id to another. | ||
| * | ||
| * Versioning Behavior specifies if and how a workflow execution moves between Worker Deployment | ||
| * Versions. The Versioning Behavior of a workflow execution is typically specified by the worker | ||
| * who completes the first task of the execution, but is also overridable manually for new and | ||
| * existing workflows (see VersioningOverride). | ||
| * Experimental. Worker Deployments are experimental and might significantly change in the future. | ||
| * | ||
| * @see \Temporal\Api\Enums\V1\VersioningBehavior | ||
| * | ||
| * @since SDK 2.16.0 | ||
| * @since RoadRunner 2025.1.3 | ||
| * @internal Experimental | ||
| */ | ||
| enum VersioningBehavior: int | ||
| { | ||
| /** | ||
| * An unspecified versioning behavior. By default, workers opting into worker versioning will be | ||
| * required to specify a behavior. | ||
| */ | ||
| case Unspecified = 0; | ||
|
|
||
| /** | ||
| * The workflow will be pinned to the current Build ID unless manually moved. | ||
| * | ||
| * Workflow will start on the Current Deployment Version of its Task Queue, and then | ||
| * will be pinned to that same Deployment Version until completion (the Version that | ||
| * this Workflow is pinned to is specified in `versioning_info.version`). | ||
| * This behavior eliminates most of compatibility concerns users face when changing their code. | ||
| * Patching is not needed when pinned workflows code change. | ||
| * Can be overridden explicitly via `UpdateWorkflowExecutionOptions` API to move the | ||
| * execution to another Deployment Version. | ||
| * Activities of `Pinned` workflows are sent to the same Deployment Version. Exception to this | ||
| * would be when the activity Task Queue workers are not present in the workflow's Deployment | ||
| * Version, in which case the activity will be sent to the Current Deployment Version of its own | ||
| * task queue. | ||
| */ | ||
| case Pinned = 1; | ||
|
|
||
| /** | ||
| * The workflow will automatically move to the latest version (default Build ID of the task queue) | ||
| * when the next task is dispatched. | ||
| * | ||
| * Workflow will automatically move to the Current Deployment Version of its Task Queue when the | ||
| * next workflow task is dispatched. | ||
| * AutoUpgrade behavior is suitable for long-running workflows as it allows them to move to the | ||
| * latest Deployment Version, but the user still needs to use Patching to keep the new code | ||
| * compatible with prior versions for changed workflow types. | ||
| * Activities of `AUTO_UPGRADE` workflows are sent to the Deployment Version of the workflow | ||
| * execution (as specified in versioning_info.version based on the last completed | ||
| * workflow task). Exception to this would be when the activity Task Queue workers are not | ||
| * present in the workflow's Deployment Version, in which case, the activity will be sent to a | ||
| * different Deployment Version according to the Current Deployment Version of its own task | ||
| * queue. | ||
| * Workflows stuck on a backlogged activity will still auto-upgrade if the Current Deployment | ||
| * Version of their Task Queue changes, without having to wait for the backlogged activity to | ||
| * complete on the old Version. | ||
| */ | ||
| case AutoUpgrade = 2; | ||
|
|
||
| public static function tryFromName(?string $name): ?self | ||
| { | ||
| return match ($name) { | ||
| 'Unspecified', null => self::Unspecified, | ||
| 'Pinned' => self::Pinned, | ||
| 'AutoUpgrade' => self::AutoUpgrade, | ||
| default => null, | ||
| }; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * This file is part of Temporal package. | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Temporal\Common\Versioning; | ||
|
|
||
| /** | ||
| * Represents the override of a worker's versioning behavior for a workflow execution. | ||
| * | ||
| * @since SDK 2.16.0 | ||
| * @since RoadRunner 2025.1.3 | ||
| * @internal Experimental | ||
| */ | ||
| final class VersioningOverride | ||
| { | ||
| private function __construct( | ||
| public readonly VersioningBehavior $behavior, | ||
| public readonly ?WorkerDeploymentVersion $version = null, | ||
| ) {} | ||
|
|
||
| /** | ||
| * The Workflow will be pinned to a specific deployment version. | ||
| */ | ||
| public static function pinned(WorkerDeploymentVersion $version): self | ||
| { | ||
| return new self( | ||
| VersioningBehavior::Pinned, | ||
| $version, | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * The Workflow will auto-upgrade to the current deployment version on the next workflow task. | ||
| */ | ||
| public static function autoUpgrade(): self | ||
| { | ||
| return new self( | ||
| VersioningBehavior::AutoUpgrade, | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Temporal\Common\Versioning; | ||
|
|
||
| use Temporal\Exception\InvalidArgumentException; | ||
| use Temporal\Internal\Marshaller\Meta\Marshal; | ||
| use Temporal\Internal\Traits\CloneWith; | ||
|
|
||
| /** | ||
| * Represents the version of a specific worker deployment. | ||
| * | ||
| * @see \Temporal\Api\Deployment\V1\WorkerDeploymentVersion | ||
| * | ||
| * @since SDK 2.16.0 | ||
| * @since RoadRunner 2025.1.3 | ||
| * @internal Experimental | ||
| */ | ||
| class WorkerDeploymentVersion implements \Stringable | ||
| { | ||
| use CloneWith; | ||
|
|
||
| private function __construct( | ||
| /** | ||
| * A unique identifier for this Version within the Deployment it is a part of. | ||
| * Not necessarily unique within the namespace. | ||
| * The combination of {@see $deployment_name} and {@see $buildId} uniquely identifies this | ||
| * Version within the namespace, because Deployment names are unique within a namespace. | ||
| */ | ||
| #[Marshal('DeploymentName')] | ||
| public readonly string $deploymentName, | ||
|
|
||
| /** | ||
| * Identifies the Worker Deployment this Version is part of. | ||
| */ | ||
| #[Marshal('BuildId')] | ||
| public readonly string $buildId, | ||
| ) {} | ||
|
|
||
| /** | ||
| * Create a new worker deployment version with the given deployment name and build ID. | ||
| * | ||
| * @param non-empty-string $deploymentName The name of the worker deployment. Must not contain a ".". | ||
| * @param non-empty-string $buildId The build ID of the worker deployment. | ||
| * | ||
| * @throws InvalidArgumentException if the deployment name or build ID is empty or invalid. | ||
| */ | ||
| public static function new(string $deploymentName, string $buildId): self | ||
| { | ||
| return new self($deploymentName, $buildId); | ||
| } | ||
|
|
||
| /** | ||
| * Build a worker deployment version from a canonical string representation. | ||
| * | ||
| * @param non-empty-string $canonicalString The canonical string representation of the worker deployment version, | ||
| * formatted as "deploymentName.buildId". Deployment name must not have a "." in it. | ||
| * | ||
| * @throws InvalidArgumentException if the input string is not in the expected format. | ||
| */ | ||
| public static function fromString(string $canonicalString): self | ||
| { | ||
| $parts = \explode('.', $canonicalString, 2); | ||
| \count($parts) === 2 or throw new InvalidArgumentException( | ||
| "Invalid canonical string format. Expected 'deploymentName.buildId'", | ||
| ); | ||
|
|
||
| return new self($parts[0], $parts[1]); | ||
| } | ||
|
|
||
| /** | ||
| * @return non-empty-string canonical string representation of this worker deployment version. | ||
| */ | ||
| public function __toString() | ||
| { | ||
| return "{$this->deploymentName}.{$this->buildId}"; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.