@@ -40,6 +40,16 @@ protected DurableTaskClient(string name)
40
40
/// </summary>
41
41
public string Name { get ; }
42
42
43
+ /// <inheritdoc cref="ScheduleNewOrchestrationInstanceAsync(TaskName, object, StartOrchestrationOptions, CancellationToken)"/>
44
+ public virtual Task < string > ScheduleNewOrchestrationInstanceAsync (
45
+ TaskName orchestratorName , CancellationToken cancellation )
46
+ => this . ScheduleNewOrchestrationInstanceAsync ( orchestratorName , null , null , cancellation ) ;
47
+
48
+ /// <inheritdoc cref="ScheduleNewOrchestrationInstanceAsync(TaskName, object, StartOrchestrationOptions, CancellationToken)"/>
49
+ public virtual Task < string > ScheduleNewOrchestrationInstanceAsync (
50
+ TaskName orchestratorName , object ? input , CancellationToken cancellation )
51
+ => this . ScheduleNewOrchestrationInstanceAsync ( orchestratorName , input , null , cancellation ) ;
52
+
43
53
/// <summary>
44
54
/// Schedules a new orchestration instance for execution.
45
55
/// </summary>
@@ -58,25 +68,38 @@ protected DurableTaskClient(string name)
58
68
/// and health of the backend task hub, and whether a start time was provided via <paramref name="options" />.
59
69
/// </para><para>
60
70
/// The task associated with this method completes after the orchestration instance was successfully scheduled. You
61
- /// can use the <see cref="GetInstanceMetadataAsync"/> to query the status of the scheduled instance, the
62
- /// <see cref="WaitForInstanceStartAsync"/> method to wait for the instance to transition out of the
63
- /// <see cref="OrchestrationRuntimeStatus.Pending"/> status, or the <see cref="WaitForInstanceCompletionAsync"/>
64
- /// method to wait for the instance to reach a terminal state (Completed, Terminated, Failed, etc.).
71
+ /// can use the <see cref="GetInstanceMetadataAsync(string, bool, CancellationToken)"/> to query the status of the
72
+ /// scheduled instance, the <see cref="WaitForInstanceStartAsync(string, bool, CancellationToken)"/> method to wait
73
+ /// for the instance to transition out of the <see cref="OrchestrationRuntimeStatus.Pending"/> status, or the
74
+ /// <see cref="WaitForInstanceCompletionAsync(string, bool, CancellationToken)"/> method to wait for the instance to
75
+ /// reach a terminal state (Completed, Terminated, Failed, etc.).
65
76
/// </para>
66
77
/// </remarks>
67
78
/// <param name="orchestratorName">The name of the orchestrator to schedule.</param>
68
79
/// <param name="input">
69
80
/// The optional input to pass to the scheduled orchestration instance. This must be a serializable value.
70
81
/// </param>
71
82
/// <param name="options">The options to start the new orchestration with.</param>
83
+ /// <param name="cancellation">
84
+ /// The cancellation token. This only cancels enqueueing the new orchestration to the backend. Does not cancel the
85
+ /// orchestration once enqueued.
86
+ /// </param>
72
87
/// <returns>
73
88
/// A task that completes when the orchestration instance is successfully scheduled. The value of this task is
74
89
/// the instance ID of the scheduled orchestration instance. If a non-null instance ID was provided via
75
90
/// <paramref name="options" />, the same value will be returned by the completed task.
76
91
/// </returns>
77
92
/// <exception cref="ArgumentNullException">Thrown if <paramref name="orchestratorName"/> is empty.</exception>
78
93
public abstract Task < string > ScheduleNewOrchestrationInstanceAsync (
79
- TaskName orchestratorName , object ? input = null , StartOrchestrationOptions ? options = null ) ;
94
+ TaskName orchestratorName ,
95
+ object ? input = null ,
96
+ StartOrchestrationOptions ? options = null ,
97
+ CancellationToken cancellation = default ) ;
98
+
99
+ /// <inheritdoc cref="RaiseEventAsync(string, string, object, CancellationToken)"/>
100
+ public virtual Task RaiseEventAsync (
101
+ string instanceId , string eventName , CancellationToken cancellation )
102
+ => this . RaiseEventAsync ( instanceId , eventName , null , cancellation ) ;
80
103
81
104
/// <summary>
82
105
/// Sends an event notification message to a waiting orchestration instance.
@@ -101,11 +124,21 @@ public abstract Task<string> ScheduleNewOrchestrationInstanceAsync(
101
124
/// <param name="instanceId">The ID of the orchestration instance that will handle the event.</param>
102
125
/// <param name="eventName">The name of the event. Event names are case-insensitive.</param>
103
126
/// <param name="eventPayload">The serializable data payload to include with the event.</param>
127
+ /// <param name="cancellation">
128
+ /// The cancellation token. This only cancels enqueueing the event to the backend. Does not abort sending the event
129
+ /// once enqueued.
130
+ /// </param>
104
131
/// <returns>A task that completes when the event notification message has been enqueued.</returns>
105
132
/// <exception cref="ArgumentNullException">
106
133
/// Thrown if <paramref name="instanceId"/> or <paramref name="eventName"/> is null or empty.
107
134
/// </exception>
108
- public abstract Task RaiseEventAsync ( string instanceId , string eventName , object ? eventPayload ) ;
135
+ public abstract Task RaiseEventAsync (
136
+ string instanceId , string eventName , object ? eventPayload = null , CancellationToken cancellation = default ) ;
137
+
138
+ /// <inheritdoc cref="TerminateAsync(string, object, CancellationToken)"/>
139
+ public virtual Task TerminateAsync (
140
+ string instanceId , CancellationToken cancellation )
141
+ => this . TerminateAsync ( instanceId , null , cancellation ) ;
109
142
110
143
/// <summary>
111
144
/// Terminates a running orchestration instance and updates its runtime status to
@@ -116,7 +149,8 @@ public abstract Task<string> ScheduleNewOrchestrationInstanceAsync(
116
149
/// This method internally enqueues a "terminate" message in the task hub. When the task hub worker processes
117
150
/// this message, it will update the runtime status of the target instance to
118
151
/// <see cref="OrchestrationRuntimeStatus.Terminated"/>. You can use the
119
- /// <see cref="WaitForInstanceCompletionAsync"/> to wait for the instance to reach the terminated state.
152
+ /// <see cref="WaitForInstanceCompletionAsync(string, bool, CancellationToken)"/> to wait for the instance to reach
153
+ /// the terminated state.
120
154
/// </para>
121
155
/// <para>
122
156
/// Terminating an orchestration instance has no effect on any in-flight activity function executions
@@ -131,8 +165,18 @@ public abstract Task<string> ScheduleNewOrchestrationInstanceAsync(
131
165
/// </remarks>
132
166
/// <param name="instanceId">The ID of the orchestration instance to terminate.</param>
133
167
/// <param name="output">The optional output to set for the terminated orchestration instance.</param>
168
+ /// <param name="cancellation">
169
+ /// The cancellation token. This only cancels enqueueing the termination request to the backend. Does not abort
170
+ /// termination of the orchestration once enqueued.
171
+ /// </param>
134
172
/// <returns>A task that completes when the terminate message is enqueued.</returns>
135
- public abstract Task TerminateAsync ( string instanceId , object ? output ) ;
173
+ public abstract Task TerminateAsync (
174
+ string instanceId , object ? output = null , CancellationToken cancellation = default ) ;
175
+
176
+ /// <inheritdoc cref="WaitForInstanceStartAsync(string, bool, CancellationToken)"/>
177
+ public virtual Task < OrchestrationMetadata > WaitForInstanceStartAsync (
178
+ string instanceId , CancellationToken cancellation )
179
+ => this . WaitForInstanceStartAsync ( instanceId , false , cancellation ) ;
136
180
137
181
/// <summary>
138
182
/// Waits for an orchestration to start running and returns a <see cref="OrchestrationMetadata"/>
@@ -147,22 +191,23 @@ public abstract Task<string> ScheduleNewOrchestrationInstanceAsync(
147
191
/// </para>
148
192
/// </remarks>
149
193
/// <param name="instanceId">The unique ID of the orchestration instance to wait for.</param>
150
- /// <param name="cancellationToken">
151
- /// A <see cref="CancellationToken"/> that can be used to cancel the wait operation.
152
- /// </param>
153
194
/// <param name="getInputsAndOutputs">
154
195
/// Specify <c>true</c> to fetch the orchestration instance's inputs, outputs, and custom status, or <c>false</c> to
155
196
/// omit them. The default value is <c>false</c> to minimize the network bandwidth, serialization, and memory costs
156
197
/// associated with fetching the instance metadata.
157
198
/// </param>
199
+ /// <param name="cancellation">A <see cref="CancellationToken"/> that can be used to cancel the wait operation.</param>
158
200
/// <returns>
159
201
/// Returns a <see cref="OrchestrationMetadata"/> record that describes the orchestration instance and its execution
160
202
/// status or <c>null</c> if no instance with ID <paramref name="instanceId"/> is found.
161
203
/// </returns>
162
204
public abstract Task < OrchestrationMetadata > WaitForInstanceStartAsync (
163
- string instanceId ,
164
- CancellationToken cancellationToken ,
165
- bool getInputsAndOutputs = false ) ;
205
+ string instanceId , bool getInputsAndOutputs = false , CancellationToken cancellation = default ) ;
206
+
207
+ /// <inheritdoc cref="WaitForInstanceCompletionAsync(string, bool, CancellationToken)"/>
208
+ public virtual Task < OrchestrationMetadata > WaitForInstanceCompletionAsync (
209
+ string instanceId , CancellationToken cancellation )
210
+ => this . WaitForInstanceCompletionAsync ( instanceId , false , cancellation ) ;
166
211
167
212
/// <summary>
168
213
/// Waits for an orchestration to complete and returns a <see cref="OrchestrationMetadata"/>
@@ -177,16 +222,19 @@ public abstract Task<OrchestrationMetadata> WaitForInstanceStartAsync(
177
222
/// Orchestrations are long-running and could take hours, days, or months before completing.
178
223
/// Orchestrations can also be eternal, in which case they'll never complete unless terminated.
179
224
/// In such cases, this call may block indefinitely, so care must be taken to ensure appropriate timeouts are
180
- /// enforced using the <paramref name="cancellationToken "/> parameter.
225
+ /// enforced using the <paramref name="cancellation "/> parameter.
181
226
/// </para><para>
182
227
/// If an orchestration instance is already complete when this method is called, the method will return immediately.
183
228
/// </para>
184
229
/// </remarks>
185
- /// <inheritdoc cref="WaitForInstanceStartAsync(string, CancellationToken, bool )"/>
230
+ /// <inheritdoc cref="WaitForInstanceStartAsync(string, bool, CancellationToken )"/>
186
231
public abstract Task < OrchestrationMetadata > WaitForInstanceCompletionAsync (
187
- string instanceId ,
188
- CancellationToken cancellationToken ,
189
- bool getInputsAndOutputs = false ) ;
232
+ string instanceId , bool getInputsAndOutputs = false , CancellationToken cancellation = default ) ;
233
+
234
+ /// <inheritdoc cref="GetInstanceMetadataAsync(string, bool, CancellationToken)"/>
235
+ public virtual Task < OrchestrationMetadata ? > GetInstanceMetadataAsync (
236
+ string instanceId , CancellationToken cancellation )
237
+ => this . GetInstanceMetadataAsync ( instanceId , false , cancellation ) ;
190
238
191
239
/// <summary>
192
240
/// Fetches orchestration instance metadata from the configured durable store.
@@ -197,13 +245,9 @@ public abstract Task<OrchestrationMetadata> WaitForInstanceCompletionAsync(
197
245
/// recommended that you set this parameter to <c>false</c> to minimize the network bandwidth, serialization, and
198
246
/// memory costs associated with fetching the instance metadata.
199
247
/// </remarks>
200
- /// <param name="instanceId">The unique ID of the orchestration instance to fetch.</param>
201
- /// <param name="getInputsAndOutputs">
202
- /// Specify <c>true</c> to fetch the orchestration instance's inputs, outputs, and custom status, or <c>false</c> to
203
- /// omit them.
204
- /// </param>
205
- /// <inheritdoc cref="WaitForInstanceStartAsync(string, CancellationToken, bool)"/>
206
- public abstract Task < OrchestrationMetadata ? > GetInstanceMetadataAsync ( string instanceId , bool getInputsAndOutputs ) ;
248
+ /// <inheritdoc cref="WaitForInstanceStartAsync(string, bool, CancellationToken)"/>
249
+ public abstract Task < OrchestrationMetadata ? > GetInstanceMetadataAsync (
250
+ string instanceId , bool getInputsAndOutputs = false , CancellationToken cancellation = default ) ;
207
251
208
252
/// <summary>
209
253
/// Queries orchestration instances.
0 commit comments