Add patch activation callback#1394
Conversation
d56263c to
7cbd856
Compare
There was a problem hiding this comment.
Implementation looks good. My one concern is around exposing WorkflowContextView::new as is. Understand it is doc hidden, but it is easy enough to find in an IDE. A free function would be less discoverable or we could at least make it clear not to depend on it.
| #[doc(hidden)] | ||
| pub fn new( |
There was a problem hiding this comment.
I understand we need someway to drive the patch activation from workflow_wasm, but I don't love exposing this interface as is. The triple Strings are begging for arg mixups.
Maybe a new small struct that carries namespace/task queue/run id and introduce a new call_patch_activation_callback(callback, workflow_info, init) here that is public hidden and handles the PatchActivationInput/WorkflowContextView construction. Still public, but harder to misuse.
7cbd856 to
d131bf6
Compare
What was changed
Added an experimental
WorkerOptions::patch_activation_callbackfor native Rust workflows that lets a worker decide whether the first newly encountered, non-replaypatchedcall activates a patch.The callback receives owned, immutable
PatchActivationInputcontaining workflow information and the patch ID. Its boolean decision is memoized for the workflow run. Declined patches returnfalsewithout recording a marker, while replay, existing history markers, and deprecated patches retain their existing behavior.WASM component workflows are intentionally excluded because supporting the host callback there requires a WIT/generated-interface expansion.
This ports the behavior introduced by temporalio/sdk-ruby#481.
Why?
This allows workflow changes using
patchedto roll out gradually without every new-code worker immediately recording a marker that older workers cannot replay.Testing
cargo test -p temporalio-sdk --libcargo test -p temporalio-workflow patch_activationcargo lintcargo test-lintcargo integ-test workflow_tests::patches: 33 cases