Skip to content

Commit 448e92f

Browse files
authored
Add new TaskOption overload for skipping input param (#110)
1 parent abd41bd commit 448e92f

File tree

5 files changed

+48
-14
lines changed

5 files changed

+48
-14
lines changed

samples/AzureFunctionsApp/AzureFunctionsApp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
34
<TargetFramework>net6.0</TargetFramework>
45
<AzureFunctionsVersion>v4</AzureFunctionsVersion>

src/Abstractions/TaskActivity.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public interface ITaskActivity
5151
/// Because activities only guarantee at least once execution, it's recommended that activity logic be implemented as
5252
/// idempotent whenever possible.
5353
/// </para><para>
54-
/// Activities are invoked by orchestrators using one of the <see cref="TaskOrchestrationContext.CallActivityAsync"/>
54+
/// Activities are invoked by orchestrators using one of the
55+
/// <see cref="TaskOrchestrationContext.CallActivityAsync(TaskName, object?, TaskOptions?)"/>
5556
/// method overloads. Activities that derive from <see cref="TaskActivity{TInput, TOutput}"/> can also be invoked
5657
/// using generated extension methods. To participate in code generation, an activity class must be decorated with the
5758
/// <see cref="DurableTaskAttribute"/> attribute. The source generator will then generate a <c>CallMyActivityAsync()</c>

src/Abstractions/TaskOrchestrationContext.cs

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,30 @@ public abstract class TaskOrchestrationContext
108108
/// <see cref="TaskFailedException.FailureDetails"/> property.
109109
/// </exception>
110110
public virtual Task CallActivityAsync(TaskName name, object? input = null, TaskOptions? options = null)
111-
{
112-
return this.CallActivityAsync<object>(name, input, options);
113-
}
111+
=> this.CallActivityAsync<object>(name, input, options);
112+
113+
/// <returns>
114+
/// A task that completes when the activity completes or fails. The result of the task is the activity's return value.
115+
/// </returns>
116+
/// <inheritdoc cref="CallActivityAsync(TaskName, object?, TaskOptions?)"/>
117+
public virtual Task CallActivityAsync(TaskName name, TaskOptions options)
118+
=> this.CallActivityAsync(name, null, options);
114119

115120
/// <returns>
116121
/// A task that completes when the activity completes or fails. The result of the task is the activity's return value.
117122
/// </returns>
118-
/// <inheritdoc cref="CallActivityAsync"/>
119-
public abstract Task<T> CallActivityAsync<T>(TaskName name, object? input = null, TaskOptions? options = null);
123+
/// <typeparam name="TResult">The type into which to deserialize the activity's output.</typeparam>
124+
/// <inheritdoc cref="CallActivityAsync(TaskName, object?, TaskOptions?)"/>
125+
public virtual Task<TResult> CallActivityAsync<TResult>(TaskName name, TaskOptions options)
126+
=> this.CallActivityAsync<TResult>(name, null, options);
127+
128+
/// <returns>
129+
/// A task that completes when the activity completes or fails. The result of the task is the activity's return value.
130+
/// </returns>
131+
/// <typeparam name="TResult">The type into which to deserialize the activity's output.</typeparam>
132+
/// <inheritdoc cref="CallActivityAsync(TaskName, object?, TaskOptions?)"/>
133+
public abstract Task<TResult> CallActivityAsync<TResult>(
134+
TaskName name, object? input = null, TaskOptions? options = null);
120135

121136
/// <summary>
122137
/// Creates a durable timer that expires after the specified delay.
@@ -247,13 +262,26 @@ public async Task<T> WaitForExternalEvent<T>(string eventName, TimeSpan timeout)
247262
/// <summary>
248263
/// Executes a named sub-orchestrator and returns the result.
249264
/// </summary>
250-
/// <typeparam name="TResult">
251-
/// The type into which to deserialize the sub-orchestrator's output.
252-
/// </typeparam>
265+
/// <typeparam name="TResult">The type into which to deserialize the sub-orchestrator's output.</typeparam>
253266
/// <inheritdoc cref="CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)"/>
254267
public abstract Task<TResult> CallSubOrchestratorAsync<TResult>(
255268
TaskName orchestratorName, object? input = null, TaskOptions? options = null);
256269

270+
/// <summary>
271+
/// Executes a named sub-orchestrator and returns the result.
272+
/// </summary>
273+
/// <typeparam name="TResult">The type into which to deserialize the sub-orchestrator's output.</typeparam>
274+
/// <inheritdoc cref="CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)"/>
275+
public virtual Task<TResult> CallSubOrchestratorAsync<TResult>(TaskName orchestratorName, TaskOptions options)
276+
=> this.CallSubOrchestratorAsync<TResult>(orchestratorName, null, options);
277+
278+
/// <summary>
279+
/// Executes a named sub-orchestrator and returns the result.
280+
/// </summary>
281+
/// <inheritdoc cref="CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)"/>
282+
public virtual Task CallSubOrchestratorAsync(TaskName orchestratorName, TaskOptions options)
283+
=> this.CallSubOrchestratorAsync(orchestratorName, null, options);
284+
257285
/// <summary>
258286
/// Executes a named sub-orchestrator.
259287
/// </summary>
@@ -296,11 +324,9 @@ public abstract Task<TResult> CallSubOrchestratorAsync<TResult>(
296324
/// The sub-orchestration failed with an unhandled exception. The details of the failure can be found in the
297325
/// <see cref="TaskFailedException.FailureDetails"/> property.
298326
/// </exception>
299-
public Task CallSubOrchestratorAsync(
327+
public virtual Task CallSubOrchestratorAsync(
300328
TaskName orchestratorName, object? input = null, TaskOptions? options = null)
301-
{
302-
return this.CallSubOrchestratorAsync<object>(orchestratorName, input, options);
303-
}
329+
=> this.CallSubOrchestratorAsync<object>(orchestratorName, input, options);
304330

305331
/// <summary>
306332
/// Restarts the orchestration with a new input and clears its history.

src/Abstractions/TaskOrchestrator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public interface ITaskOrchestrator
4545
/// </para>
4646
/// <para>
4747
/// Orchestrators can be scheduled using an external client (see Microsoft.DurableTask.Client). Orchestrators can
48-
/// also invoke child orchestrators using the <see cref="TaskOrchestrationContext.CallSubOrchestratorAsync"/> method.
48+
/// also invoke child orchestrators using the
49+
/// <see cref="TaskOrchestrationContext.CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)"/> method.
4950
/// Orchestrators that derive from <see cref="TaskOrchestrator{TInput, TOutput}"/> can also be invoked using
5051
/// generated extension methods. To participate in code generation, an orchestrator class must be decorated with the
5152
/// <see cref="DurableTaskAttribute"/> attribute. The source generator will then generate a

src/Client/Core/DurableTaskClient.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public virtual Task<string> ScheduleNewOrchestrationInstanceAsync(
5050
TaskName orchestratorName, object? input, CancellationToken cancellation)
5151
=> this.ScheduleNewOrchestrationInstanceAsync(orchestratorName, input, null, cancellation);
5252

53+
/// <inheritdoc cref="ScheduleNewOrchestrationInstanceAsync(TaskName, object, StartOrchestrationOptions, CancellationToken)"/>
54+
public virtual Task<string> ScheduleNewOrchestrationInstanceAsync(
55+
TaskName orchestratorName, StartOrchestrationOptions options, CancellationToken cancellation = default)
56+
=> this.ScheduleNewOrchestrationInstanceAsync(orchestratorName, null, options, cancellation);
57+
5358
/// <summary>
5459
/// Schedules a new orchestration instance for execution.
5560
/// </summary>

0 commit comments

Comments
 (0)