Skip to content

Commit fec3f7a

Browse files
authored
Make DurableTaskClient method names consistent (#112)
1 parent 448e92f commit fec3f7a

File tree

10 files changed

+127
-112
lines changed

10 files changed

+127
-112
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
## v1.0.0
44

55
- Added `SuspendInstanceAsync` and `ResumeInstanceAsync` to `DurableTaskClient`.
6+
- Rename `DurableTaskClient` methods
7+
- `TerminateAsync` -> `TerminateInstanceAsync`
8+
- `PurgeInstances` -> `PurgeAllInstancesAsync`
9+
- `PurgeInstanceMetadataAsync` -> `PurgeInstanceAsync`
10+
- `GetInstanceMetadataAsync` -> `GetInstanceAsync`
11+
- `GetInstances` -> `GetAllInstancesAsync`
612
- `TaskOrchestrationContext.CreateReplaySafeLogger` now creates `ILogger` directly (as opposed to wrapping an existing `ILogger`).
713
- Durable Functions class-based syntax now resolves `ITaskActivity` instances from `IServiceProvider`, if available there.
814
- `DurableTaskClient` methods have been touched up to ensure `CancellationToken` is included, as well as is the last parameter.

src/Client/Core/DependencyInjection/DurableTaskClientExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static Task<PurgeResult> PurgeInstancesAsync(
3030
{
3131
Check.NotNull(client);
3232
PurgeInstancesFilter filter = new(createdFrom, createdTo, statuses);
33-
return client.PurgeInstancesAsync(filter, cancellation);
33+
return client.PurgeAllInstancesAsync(filter, cancellation);
3434
}
3535

3636
/// <summary>

src/Client/Core/DurableTaskClient.cs

Lines changed: 80 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public virtual Task<string> ScheduleNewOrchestrationInstanceAsync(
7373
/// and health of the backend task hub, and whether a start time was provided via <paramref name="options" />.
7474
/// </para><para>
7575
/// The task associated with this method completes after the orchestration instance was successfully scheduled. You
76-
/// can use the <see cref="GetInstanceMetadataAsync(string, bool, CancellationToken)"/> to query the status of the
76+
/// can use the <see cref="GetInstancesAsync(string, bool, CancellationToken)"/> to query the status of the
7777
/// scheduled instance, the <see cref="WaitForInstanceStartAsync(string, bool, CancellationToken)"/> method to wait
7878
/// for the instance to transition out of the <see cref="OrchestrationRuntimeStatus.Pending"/> status, or the
7979
/// <see cref="WaitForInstanceCompletionAsync(string, bool, CancellationToken)"/> method to wait for the instance to
@@ -140,10 +140,67 @@ public virtual Task RaiseEventAsync(
140140
public abstract Task RaiseEventAsync(
141141
string instanceId, string eventName, object? eventPayload = null, CancellationToken cancellation = default);
142142

143-
/// <inheritdoc cref="TerminateAsync(string, object, CancellationToken)"/>
144-
public virtual Task TerminateAsync(
143+
/// <inheritdoc cref="WaitForInstanceStartAsync(string, bool, CancellationToken)"/>
144+
public virtual Task<OrchestrationMetadata> WaitForInstanceStartAsync(
145+
string instanceId, CancellationToken cancellation)
146+
=> this.WaitForInstanceStartAsync(instanceId, false, cancellation);
147+
148+
/// <summary>
149+
/// Waits for an orchestration to start running and returns a <see cref="OrchestrationMetadata"/>
150+
/// object that contains metadata about the started instance.
151+
/// </summary>
152+
/// <remarks>
153+
/// <para>
154+
/// A "started" orchestration instance is any instance not in the <see cref="OrchestrationRuntimeStatus.Pending"/>
155+
/// state.
156+
/// </para><para>
157+
/// If an orchestration instance is already running when this method is called, the method will return immediately.
158+
/// </para>
159+
/// </remarks>
160+
/// <param name="instanceId">The unique ID of the orchestration instance to wait for.</param>
161+
/// <param name="getInputsAndOutputs">
162+
/// Specify <c>true</c> to fetch the orchestration instance's inputs, outputs, and custom status, or <c>false</c> to
163+
/// omit them. The default value is <c>false</c> to minimize the network bandwidth, serialization, and memory costs
164+
/// associated with fetching the instance metadata.
165+
/// </param>
166+
/// <param name="cancellation">A <see cref="CancellationToken"/> that can be used to cancel the wait operation.</param>
167+
/// <returns>
168+
/// Returns a <see cref="OrchestrationMetadata"/> record that describes the orchestration instance and its execution
169+
/// status or <c>null</c> if no instance with ID <paramref name="instanceId"/> is found.
170+
/// </returns>
171+
public abstract Task<OrchestrationMetadata> WaitForInstanceStartAsync(
172+
string instanceId, bool getInputsAndOutputs = false, CancellationToken cancellation = default);
173+
174+
/// <inheritdoc cref="WaitForInstanceCompletionAsync(string, bool, CancellationToken)"/>
175+
public virtual Task<OrchestrationMetadata> WaitForInstanceCompletionAsync(
145176
string instanceId, CancellationToken cancellation)
146-
=> this.TerminateAsync(instanceId, null, cancellation);
177+
=> this.WaitForInstanceCompletionAsync(instanceId, false, cancellation);
178+
179+
/// <summary>
180+
/// Waits for an orchestration to complete and returns a <see cref="OrchestrationMetadata"/>
181+
/// object that contains metadata about the started instance.
182+
/// </summary>
183+
/// <remarks>
184+
/// <para>
185+
/// A "completed" orchestration instance is any instance in one of the terminal states. For example, the
186+
/// <see cref="OrchestrationRuntimeStatus.Completed"/>, <see cref="OrchestrationRuntimeStatus.Failed"/>, or
187+
/// <see cref="OrchestrationRuntimeStatus.Terminated"/> states.
188+
/// </para><para>
189+
/// Orchestrations are long-running and could take hours, days, or months before completing.
190+
/// Orchestrations can also be eternal, in which case they'll never complete unless terminated.
191+
/// In such cases, this call may block indefinitely, so care must be taken to ensure appropriate timeouts are
192+
/// enforced using the <paramref name="cancellation"/> parameter.
193+
/// </para><para>
194+
/// If an orchestration instance is already complete when this method is called, the method will return immediately.
195+
/// </para>
196+
/// </remarks>
197+
/// <inheritdoc cref="WaitForInstanceStartAsync(string, bool, CancellationToken)"/>
198+
public abstract Task<OrchestrationMetadata> WaitForInstanceCompletionAsync(
199+
string instanceId, bool getInputsAndOutputs = false, CancellationToken cancellation = default);
200+
201+
/// <inheritdoc cref="TerminateInstanceAsync(string, object, CancellationToken)"/>
202+
public virtual Task TerminateInstanceAsync(string instanceId, CancellationToken cancellation)
203+
=> this.TerminateInstanceAsync(instanceId, null, cancellation);
147204

148205
/// <summary>
149206
/// Terminates a running orchestration instance and updates its runtime status to
@@ -175,17 +232,16 @@ public virtual Task TerminateAsync(
175232
/// termination of the orchestration once enqueued.
176233
/// </param>
177234
/// <returns>A task that completes when the terminate message is enqueued.</returns>
178-
public abstract Task TerminateAsync(
235+
public abstract Task TerminateInstanceAsync(
179236
string instanceId, object? output = null, CancellationToken cancellation = default);
180237

181-
/// <inheritdoc cref="WaitForInstanceStartAsync(string, bool, CancellationToken)"/>
182-
public virtual Task<OrchestrationMetadata> WaitForInstanceStartAsync(
183-
string instanceId, CancellationToken cancellation)
184-
=> this.WaitForInstanceStartAsync(instanceId, false, cancellation);
238+
/// <inheritdoc cref="SuspendInstanceAsync(string, string, CancellationToken)"/>
239+
public virtual Task SuspendInstanceAsync(string instanceId, CancellationToken cancellation)
240+
=> this.SuspendInstanceAsync(instanceId, null, cancellation);
185241

186242
/// <summary>
187-
/// Suspends an orchestration instance, halting processing of it until <see cref="ResumeInstanceAsync" /> is used
188-
/// to resume the orchestration.
243+
/// Suspends an orchestration instance, halting processing of it until
244+
/// <see cref="ResumeInstanceAsync(string, string, CancellationToken)" /> is used to resume the orchestration.
189245
/// </summary>
190246
/// <param name="instanceId">The instance ID of the orchestration to suspend.</param>
191247
/// <param name="reason">The optional suspension reason.</param>
@@ -197,8 +253,12 @@ public virtual Task<OrchestrationMetadata> WaitForInstanceStartAsync(
197253
public abstract Task SuspendInstanceAsync(
198254
string instanceId, string? reason = null, CancellationToken cancellation = default);
199255

256+
/// <inheritdoc cref="ResumeInstanceAsync(string, string, CancellationToken)"/>
257+
public virtual Task ResumeInstanceAsync(string instanceId, CancellationToken cancellation)
258+
=> this.ResumeInstanceAsync(instanceId, null, cancellation);
259+
200260
/// <summary>
201-
/// Resumes an orchestration instance that was suspended via <see cref="SuspendInstanceAsync" />.
261+
/// Resumes an orchestration instance that was suspended via <see cref="SuspendInstanceAsync(string, string, CancellationToken)" />.
202262
/// </summary>
203263
/// <param name="instanceId">The instance ID of the orchestration to resume.</param>
204264
/// <param name="reason">The optional resume reason.</param>
@@ -210,63 +270,10 @@ public abstract Task SuspendInstanceAsync(
210270
public abstract Task ResumeInstanceAsync(
211271
string instanceId, string? reason = null, CancellationToken cancellation = default);
212272

213-
/// <summary>
214-
/// Waits for an orchestration to start running and returns a <see cref="OrchestrationMetadata"/>
215-
/// object that contains metadata about the started instance.
216-
/// </summary>
217-
/// <remarks>
218-
/// <para>
219-
/// A "started" orchestration instance is any instance not in the <see cref="OrchestrationRuntimeStatus.Pending"/>
220-
/// state.
221-
/// </para><para>
222-
/// If an orchestration instance is already running when this method is called, the method will return immediately.
223-
/// </para>
224-
/// </remarks>
225-
/// <param name="instanceId">The unique ID of the orchestration instance to wait for.</param>
226-
/// <param name="getInputsAndOutputs">
227-
/// Specify <c>true</c> to fetch the orchestration instance's inputs, outputs, and custom status, or <c>false</c> to
228-
/// omit them. The default value is <c>false</c> to minimize the network bandwidth, serialization, and memory costs
229-
/// associated with fetching the instance metadata.
230-
/// </param>
231-
/// <param name="cancellation">A <see cref="CancellationToken"/> that can be used to cancel the wait operation.</param>
232-
/// <returns>
233-
/// Returns a <see cref="OrchestrationMetadata"/> record that describes the orchestration instance and its execution
234-
/// status or <c>null</c> if no instance with ID <paramref name="instanceId"/> is found.
235-
/// </returns>
236-
public abstract Task<OrchestrationMetadata> WaitForInstanceStartAsync(
237-
string instanceId, bool getInputsAndOutputs = false, CancellationToken cancellation = default);
238-
239-
/// <inheritdoc cref="WaitForInstanceCompletionAsync(string, bool, CancellationToken)"/>
240-
public virtual Task<OrchestrationMetadata> WaitForInstanceCompletionAsync(
241-
string instanceId, CancellationToken cancellation)
242-
=> this.WaitForInstanceCompletionAsync(instanceId, false, cancellation);
243-
244-
/// <summary>
245-
/// Waits for an orchestration to complete and returns a <see cref="OrchestrationMetadata"/>
246-
/// object that contains metadata about the started instance.
247-
/// </summary>
248-
/// <remarks>
249-
/// <para>
250-
/// A "completed" orchestration instance is any instance in one of the terminal states. For example, the
251-
/// <see cref="OrchestrationRuntimeStatus.Completed"/>, <see cref="OrchestrationRuntimeStatus.Failed"/>, or
252-
/// <see cref="OrchestrationRuntimeStatus.Terminated"/> states.
253-
/// </para><para>
254-
/// Orchestrations are long-running and could take hours, days, or months before completing.
255-
/// Orchestrations can also be eternal, in which case they'll never complete unless terminated.
256-
/// In such cases, this call may block indefinitely, so care must be taken to ensure appropriate timeouts are
257-
/// enforced using the <paramref name="cancellation"/> parameter.
258-
/// </para><para>
259-
/// If an orchestration instance is already complete when this method is called, the method will return immediately.
260-
/// </para>
261-
/// </remarks>
262-
/// <inheritdoc cref="WaitForInstanceStartAsync(string, bool, CancellationToken)"/>
263-
public abstract Task<OrchestrationMetadata> WaitForInstanceCompletionAsync(
264-
string instanceId, bool getInputsAndOutputs = false, CancellationToken cancellation = default);
265-
266-
/// <inheritdoc cref="GetInstanceMetadataAsync(string, bool, CancellationToken)"/>
267-
public virtual Task<OrchestrationMetadata?> GetInstanceMetadataAsync(
273+
/// <inheritdoc cref="GetInstancesAsync(string, bool, CancellationToken)"/>
274+
public virtual Task<OrchestrationMetadata?> GetInstancesAsync(
268275
string instanceId, CancellationToken cancellation)
269-
=> this.GetInstanceMetadataAsync(instanceId, false, cancellation);
276+
=> this.GetInstancesAsync(instanceId, false, cancellation);
270277

271278
/// <summary>
272279
/// Fetches orchestration instance metadata from the configured durable store.
@@ -278,15 +285,15 @@ public abstract Task<OrchestrationMetadata> WaitForInstanceCompletionAsync(
278285
/// memory costs associated with fetching the instance metadata.
279286
/// </remarks>
280287
/// <inheritdoc cref="WaitForInstanceStartAsync(string, bool, CancellationToken)"/>
281-
public abstract Task<OrchestrationMetadata?> GetInstanceMetadataAsync(
288+
public abstract Task<OrchestrationMetadata?> GetInstancesAsync(
282289
string instanceId, bool getInputsAndOutputs = false, CancellationToken cancellation = default);
283290

284291
/// <summary>
285292
/// Queries orchestration instances.
286293
/// </summary>
287-
/// <param name="query">Filters down the instances included in the query.</param>
294+
/// <param name="filter">Filters down the instances included in the query.</param>
288295
/// <returns>An async pageable of the query results.</returns>
289-
public abstract AsyncPageable<OrchestrationMetadata> GetInstances(OrchestrationQuery? query = null);
296+
public abstract AsyncPageable<OrchestrationMetadata> GetAllInstancesAsync(OrchestrationQuery? filter = null);
290297

291298
/// <summary>
292299
/// Purges orchestration instance metadata from the durable store.
@@ -314,7 +321,7 @@ public abstract Task<OrchestrationMetadata> WaitForInstanceCompletionAsync(
314321
/// <see cref="PurgeResult.PurgedInstanceCount"/> value of <c>1</c> or <c>0</c>, depending on whether the target
315322
/// instance was successfully purged.
316323
/// </returns>
317-
public abstract Task<PurgeResult> PurgeInstanceMetadataAsync(
324+
public abstract Task<PurgeResult> PurgeInstanceAsync(
318325
string instanceId, CancellationToken cancellation = default);
319326

320327
/// <summary>
@@ -328,7 +335,7 @@ public abstract Task<PurgeResult> PurgeInstanceMetadataAsync(
328335
/// This method returns a <see cref="PurgeResult"/> object after the operation has completed with a
329336
/// <see cref="PurgeResult.PurgedInstanceCount"/> indicating the number of orchestration instances that were purged.
330337
/// </returns>
331-
public abstract Task<PurgeResult> PurgeInstancesAsync(
338+
public abstract Task<PurgeResult> PurgeAllInstancesAsync(
332339
PurgeInstancesFilter filter, CancellationToken cancellation = default);
333340

334341
// TODO: Create task hub

src/Client/Core/OrchestrationMetadata.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.DurableTask.Client;
1111
/// </summary>
1212
/// <remarks>
1313
/// Instances of this class are produced by methods in the <see cref="DurableTaskClient"/> class, such as
14-
/// <see cref="DurableTaskClient.GetInstanceMetadataAsync(string, CancellationToken)"/>,
14+
/// <see cref="DurableTaskClient.GetInstancesAsync(string, CancellationToken)"/>,
1515
/// <see cref="DurableTaskClient.WaitForInstanceStartAsync(string, CancellationToken)"/> and
1616
/// <see cref="DurableTaskClient.WaitForInstanceCompletionAsync(string, CancellationToken)"/>.
1717
/// </remarks>
@@ -117,7 +117,7 @@ public OrchestrationMetadata(string name, string instanceId)
117117
/// </summary>
118118
/// <remarks>
119119
/// This method can only be used when inputs and outputs are explicitly requested from the
120-
/// <see cref="DurableTaskClient.GetInstanceMetadataAsync(string, CancellationToken)"/> or
120+
/// <see cref="DurableTaskClient.GetInstancesAsync(string, CancellationToken)"/> or
121121
/// <see cref="DurableTaskClient.WaitForInstanceCompletionAsync(string, CancellationToken)"/> method that produced
122122
/// this <see cref="OrchestrationMetadata"/> object.
123123
/// </remarks>
@@ -143,7 +143,7 @@ public OrchestrationMetadata(string name, string instanceId)
143143
/// </summary>
144144
/// <remarks>
145145
/// This method can only be used when inputs and outputs are explicitly requested from the
146-
/// <see cref="DurableTaskClient.GetInstanceMetadataAsync(string, CancellationToken)"/> or
146+
/// <see cref="DurableTaskClient.GetInstancesAsync(string, CancellationToken)"/> or
147147
/// <see cref="DurableTaskClient.WaitForInstanceCompletionAsync(string, CancellationToken)"/> method that produced
148148
/// this <see cref="OrchestrationMetadata"/> object.
149149
/// </remarks>
@@ -169,7 +169,7 @@ public OrchestrationMetadata(string name, string instanceId)
169169
/// </summary>
170170
/// <remarks>
171171
/// This method can only be used when inputs and outputs are explicitly requested from the
172-
/// <see cref="DurableTaskClient.GetInstanceMetadataAsync(string, CancellationToken)"/> or
172+
/// <see cref="DurableTaskClient.GetInstancesAsync(string, CancellationToken)"/> or
173173
/// <see cref="DurableTaskClient.WaitForInstanceCompletionAsync(string, CancellationToken)"/> method that produced
174174
/// this <see cref="OrchestrationMetadata"/> object.
175175
/// </remarks>

src/Client/Core/PurgeInstancesFilter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace Microsoft.DurableTask.Client;
1010
/// <param name="CreatedTo">Date created to.</param>
1111
/// <param name="Statuses">The statuses.</param>
1212
public record PurgeInstancesFilter(
13-
DateTimeOffset? CreatedFrom, DateTimeOffset? CreatedTo, IEnumerable<OrchestrationRuntimeStatus>? Statuses)
13+
DateTimeOffset? CreatedFrom = null,
14+
DateTimeOffset? CreatedTo = null,
15+
IEnumerable<OrchestrationRuntimeStatus>? Statuses = null)
1416
{
1517
}

0 commit comments

Comments
 (0)