21
21
use Temporal \Common \MethodRetry ;
22
22
use Temporal \Common \RetryOptions ;
23
23
use Temporal \Common \Uuid ;
24
+ use Temporal \Common \WorkflowIdConflictPolicy ;
24
25
use Temporal \DataConverter \DataConverterInterface ;
25
26
use Temporal \Internal \Marshaller \Meta \Marshal ;
26
27
use Temporal \Internal \Marshaller \Type \ArrayType ;
@@ -98,12 +99,19 @@ final class WorkflowOptions extends Options
98
99
public \DateInterval $ workflowTaskTimeout ;
99
100
100
101
/**
101
- * Whether server allow reuse of workflow ID, can be useful for deduplication logic.
102
- * If set to {@see IdReusePolicy::POLICY_REJECT_DUPLICATE}.
102
+ * Whether server allow reuse of workflow ID.
103
+ *
104
+ * Can be useful for deduplication logic if set to {@see IdReusePolicy::POLICY_REJECT_DUPLICATE}.
103
105
*/
104
106
#[Marshal(name: 'WorkflowIDReusePolicy ' )]
105
107
public int $ workflowIdReusePolicy = IdReusePolicy::POLICY_ALLOW_DUPLICATE_FAILED_ONLY ;
106
108
109
+ /**
110
+ * Defines how to resolve an ID conflict with a *running* workflow.
111
+ */
112
+ #[Marshal(name: 'WorkflowIdConflictPolicy ' )]
113
+ public WorkflowIdConflictPolicy $ workflowIdConflictPolicy = WorkflowIdConflictPolicy::Unspecified;
114
+
107
115
/**
108
116
* Optional retry policy for workflow. If a retry policy is specified, in
109
117
* case of workflow failure server will start new workflow execution if
@@ -319,8 +327,8 @@ public function withWorkflowStartDelay($delay): self
319
327
}
320
328
321
329
/**
322
- * Specifies server behavior if a completed workflow with the same id
323
- * exists. Note that under no conditions Temporal allows two workflows
330
+ * Specifies server behavior if a *closed* workflow with the same id exists.
331
+ * Note that under no conditions Temporal allows two workflows
324
332
* with the same namespace and workflow id run simultaneously.
325
333
*
326
334
* - {@see IdReusePolicy::AllowDuplicateFailedOnly}: Is a default
@@ -347,6 +355,21 @@ public function withWorkflowIdReusePolicy(IdReusePolicy|int $policy): self
347
355
return $ self ;
348
356
}
349
357
358
+ /**
359
+ * Defines how to resolve an ID conflict with a *running* workflow.
360
+ *
361
+ * @psalm-suppress ImpureMethodCall
362
+ *
363
+ * @return $this
364
+ */
365
+ #[Pure]
366
+ public function withWorkflowIdConflictPolicy (WorkflowIdConflictPolicy $ policy ): self
367
+ {
368
+ $ self = clone $ this ;
369
+ $ self ->workflowIdConflictPolicy = $ policy ;
370
+ return $ self ;
371
+ }
372
+
350
373
/**
351
374
* RetryOptions that define how child workflow is retried in case of
352
375
* failure. Default is null which is no reties.
0 commit comments