Add patch activation callback#782
Open
Sushisource wants to merge 2 commits into
Open
Conversation
03d9b5d to
3ef7ca1
Compare
3ef7ca1 to
81323b6
Compare
81323b6 to
8399fc4
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What was changed
Added an experimental
TemporalWorkerOptions.PatchActivationCallbackthat lets a worker decide whether the first newly encountered, non-replayWorkflow.Patchedcall activates a patch.The callback receives workflow information and the patch ID. Its boolean decision is memoized for the workflow run. Declined patches return
falsewithout recording a marker, while replay, existing history markers, and deprecated patches retain their existing behavior.This ports the behavior introduced by temporalio/sdk-ruby#481.
The work is intentionally split into two commits:
Add patch activation callbackcontains only the callback API, plumbing, activation semantics, and rollout tests.Harden read-only workflow contextsmakes the callback read-only and completes the workflow context's read-only enforcement. This includes guarding nested patches, workflow metadata and handler mutation, continue-as-new, and patch calls from queries and update validators.Note
We can drop the second commit if it feels like too much to put in the PR, but, it's done and I think adds some nice safety.
Why?
This allows workflow changes using
Workflow.Patchedto roll out gradually without every new-code worker immediately recording a marker that older workers cannot replay.Keeping the read-only hardening in a subsequent commit separates the callback's intended behavior from the broader workflow-context consistency fixes discovered during review.
Testing