Expand description
Ordered worker interceptors around workflow tasks, activities, queries and update validations.
Register interceptors with Worker::interceptor
or Worker::interceptors. The first
registered interceptor is the outermost wrapper: it runs first before the
core and last after it. Each hook receives a context and a next handle;
running next continues the chain and the innermost next runs the
SDK’s real handling. Every hook has a passthrough default, so an
interceptor implements only the hooks it needs.
| Hook | Wraps | Context | next returns |
|---|---|---|---|
WorkerInterceptor::execute_workflow_task | one workflow task (replay plus new execution) | WorkflowTaskInterceptorContext | WorkflowTaskOutcome |
WorkerInterceptor::execute_activity | one activity or local activity attempt | ActivityInterceptorContext | the activity result |
WorkerInterceptor::execute_query_task | one query task | QueryTaskInterceptorContext | the query result or QueryTaskFailure |
WorkerInterceptor::execute_update_validation_task | one update-validation task | UpdateValidationInterceptorContext | a read-only UpdateValidationOutcome |
Workflow-task interceptors cannot change what the workflow records. The
core always runs the task as received (WorkflowTaskNext::run takes no
input) and the worker submits exactly the commands the core produced. The
outcome an interceptor sees is a read-only view. If the core fails, the
worker reports that failure even when an interceptor returns Ok. If an
interceptor fails after the core succeeded, or returns without running
next, the worker fails the workflow task (Error::WorkflowTaskInterceptor);
nothing is recorded and the Server retries the task. Interceptors run on
every workflow task. WorkflowTaskInterceptorContext::replay_state says
whether the task first re-ran a committed history prefix; the worker never
resubmits replayed commands, so an outcome’s commands are always new for
that task. A failed task’s retry can repeat an outcome; use
WorkflowTaskInterceptorContext::attempt to detect retries.
Update-validation interceptors observe a validator’s decision and cannot
change it. The validator always runs on the task as received
(UpdateValidationNext::run takes no input) and the worker sends the
validator’s own approval or rejection. If an interceptor fails, returns
without running next, or drops the validation partway, the worker reports
update_validation_worker_failed instead: the update is not accepted, and
the caller’s retry with the same request id asks the validator again.
Built-in ExecutionTelemetry stays
outermost: its spans wrap the whole interceptor chain.
Structs§
- Activity
Interceptor Context - Context of one activity attempt; owns the arguments passed down the chain.
- Activity
Next - Continues an activity chain; the innermost
nextruns the activity. - Passthrough
Worker Interceptor - An interceptor that only calls
next; a base for partial interceptors. - Query
Task Failure - A query task failure the worker reports to the Server.
- Query
Task Interceptor Context - Read-only context of one query task.
- Query
Task Next - Continues a query chain; the innermost
nextanswers the query. - Update
Validation Interceptor Context - Read-only context of one update-validation task.
- Update
Validation Next - Continues an update-validation chain; the innermost
nextruns the validator. - Update
Validation Outcome - A read-only view of the decision the validator produced.
- Workflow
Task Failure - A read-only description of the workflow-task core’s own error.
- Workflow
Task Interceptor Context - Read-only context of one workflow task.
- Workflow
Task Next - Continues a workflow-task chain; the innermost
nextruns the task. - Workflow
Task Outcome - A read-only view of what the workflow-task core produced.
Traits§
- Worker
Interceptor - Ordered hooks around worker task execution.
Type Aliases§
- Interceptor
Future - The boxed
Sendfuture an interceptor hook returns.