|
40 | 40 | _DEFAULT_WORKFLOW_TASK_EXTERNAL_STORAGE_CONCURRENCY, |
41 | 41 | _WorkflowWorker, |
42 | 42 | ) |
43 | | -from ._workflow_instance import UnsandboxedWorkflowRunner, WorkflowRunner |
| 43 | +from ._workflow_instance import ( |
| 44 | + PatchActivationInput, |
| 45 | + UnsandboxedWorkflowRunner, |
| 46 | + WorkflowRunner, |
| 47 | +) |
44 | 48 | from .workflow_sandbox import SandboxedWorkflowRunner |
45 | 49 |
|
46 | 50 | logger = logging.getLogger(__name__) |
@@ -135,6 +139,7 @@ def __init__( |
135 | 139 | use_worker_versioning: bool = False, |
136 | 140 | disable_safe_workflow_eviction: bool = False, |
137 | 141 | deployment_config: WorkerDeploymentConfig | None = None, |
| 142 | + patch_activation_callback: Callable[[PatchActivationInput], bool] | None = None, |
138 | 143 | workflow_task_poller_behavior: PollerBehavior = PollerBehaviorSimpleMaximum( |
139 | 144 | maximum=5 |
140 | 145 | ), |
@@ -307,6 +312,12 @@ def __init__( |
307 | 312 | deployment_config: Deployment config for the worker. Exclusive with ``build_id`` and |
308 | 313 | ``use_worker_versioning``. |
309 | 314 | WARNING: This is an experimental feature and may change in the future. |
| 315 | + patch_activation_callback: Callback to decide whether the first non-replay |
| 316 | + call to :py:func:`workflow.patched<temporalio.workflow.patched>` for a |
| 317 | + patch ID should activate that patch. The callback receives a |
| 318 | + :py:class:`PatchActivationInput` and must return ``True`` to activate the |
| 319 | + patch or ``False`` to leave it inactive. |
| 320 | + WARNING: This is an experimental feature and may change in the future. |
310 | 321 | workflow_task_poller_behavior: Specify the behavior of workflow task polling. |
311 | 322 | Defaults to a 5-poller maximum. |
312 | 323 | activity_task_poller_behavior: Specify the behavior of activity task polling. |
@@ -368,6 +379,7 @@ def __init__( |
368 | 379 | use_worker_versioning=use_worker_versioning, |
369 | 380 | disable_safe_workflow_eviction=disable_safe_workflow_eviction, |
370 | 381 | deployment_config=deployment_config, |
| 382 | + patch_activation_callback=patch_activation_callback, |
371 | 383 | workflow_task_poller_behavior=workflow_task_poller_behavior, |
372 | 384 | activity_task_poller_behavior=activity_task_poller_behavior, |
373 | 385 | nexus_task_poller_behavior=nexus_task_poller_behavior, |
@@ -528,6 +540,7 @@ def check_activity(activity: str): |
528 | 540 | workflow_failure_exception_types=config[ |
529 | 541 | "workflow_failure_exception_types" |
530 | 542 | ], # type: ignore[reportTypedDictNotRequiredAccess] |
| 543 | + patch_activation_callback=config.get("patch_activation_callback"), |
531 | 544 | debug_mode=config["debug_mode"], # type: ignore[reportTypedDictNotRequiredAccess] |
532 | 545 | disable_eager_activity_execution=config[ |
533 | 546 | "disable_eager_activity_execution" |
@@ -982,6 +995,7 @@ class WorkerConfig(TypedDict, total=False): |
982 | 995 | use_worker_versioning: bool |
983 | 996 | disable_safe_workflow_eviction: bool |
984 | 997 | deployment_config: WorkerDeploymentConfig | None |
| 998 | + patch_activation_callback: Callable[[PatchActivationInput], bool] | None |
985 | 999 | workflow_task_poller_behavior: PollerBehavior |
986 | 1000 | activity_task_poller_behavior: PollerBehavior |
987 | 1001 | nexus_task_poller_behavior: PollerBehavior |
|
0 commit comments