Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new TaskOption overload for skipping input param #110

Merged
merged 3 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions samples/AzureFunctionsApp/AzureFunctionsApp.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

jviau marked this conversation as resolved.
Show resolved Hide resolved
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
Expand Down
3 changes: 2 additions & 1 deletion src/Abstractions/TaskActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public interface ITaskActivity
/// Because activities only guarantee at least once execution, it's recommended that activity logic be implemented as
/// idempotent whenever possible.
/// </para><para>
/// Activities are invoked by orchestrators using one of the <see cref="TaskOrchestrationContext.CallActivityAsync"/>
/// Activities are invoked by orchestrators using one of the
/// <see cref="TaskOrchestrationContext.CallActivityAsync(TaskName, object?, TaskOptions?)"/>
/// method overloads. Activities that derive from <see cref="TaskActivity{TInput, TOutput}"/> can also be invoked
/// using generated extension methods. To participate in code generation, an activity class must be decorated with the
/// <see cref="DurableTaskAttribute"/> attribute. The source generator will then generate a <c>CallMyActivityAsync()</c>
Expand Down
50 changes: 38 additions & 12 deletions src/Abstractions/TaskOrchestrationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,30 @@ public abstract class TaskOrchestrationContext
/// <see cref="TaskFailedException.FailureDetails"/> property.
/// </exception>
public virtual Task CallActivityAsync(TaskName name, object? input = null, TaskOptions? options = null)
{
return this.CallActivityAsync<object>(name, input, options);
}
=> this.CallActivityAsync<object>(name, input, options);

/// <returns>
/// A task that completes when the activity completes or fails. The result of the task is the activity's return value.
/// </returns>
/// <inheritdoc cref="CallActivityAsync(TaskName, object?, TaskOptions?)"/>
public virtual Task CallActivityAsync(TaskName name, TaskOptions options)
=> this.CallActivityAsync(name, null, options);
Comment on lines +112 to +118
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we really inherit the docs from the CallActivityAsync with the input parameter?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment for the changes in CallSubOrchestrator

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I don't really know the answer to that. @cgillum suggested I do it on another PR so I did 🤷

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, even if this were off, it's a non-blocking concern


/// <returns>
/// A task that completes when the activity completes or fails. The result of the task is the activity's return value.
/// </returns>
/// <inheritdoc cref="CallActivityAsync"/>
public abstract Task<T> CallActivityAsync<T>(TaskName name, object? input = null, TaskOptions? options = null);
/// <typeparam name="TResult">The type into which to deserialize the activity's output.</typeparam>
/// <inheritdoc cref="CallActivityAsync(TaskName, object?, TaskOptions?)"/>
public virtual Task<TResult> CallActivityAsync<TResult>(TaskName name, TaskOptions options)
=> this.CallActivityAsync<TResult>(name, null, options);

/// <returns>
/// A task that completes when the activity completes or fails. The result of the task is the activity's return value.
/// </returns>
/// <typeparam name="TResult">The type into which to deserialize the activity's output.</typeparam>
/// <inheritdoc cref="CallActivityAsync(TaskName, object?, TaskOptions?)"/>
public abstract Task<TResult> CallActivityAsync<TResult>(
TaskName name, object? input = null, TaskOptions? options = null);

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

/// <summary>
/// Executes a named sub-orchestrator and returns the result.
/// </summary>
/// <typeparam name="TResult">The type into which to deserialize the sub-orchestrator's output.</typeparam>
/// <inheritdoc cref="CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)"/>
public virtual Task<TResult> CallSubOrchestratorAsync<TResult>(TaskName orchestratorName, TaskOptions options)
=> this.CallSubOrchestratorAsync<TResult>(orchestratorName, null, options);

/// <summary>
/// Executes a named sub-orchestrator and returns the result.
/// </summary>
/// <inheritdoc cref="CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)"/>
public virtual Task CallSubOrchestratorAsync(TaskName orchestratorName, TaskOptions options)
=> this.CallSubOrchestratorAsync(orchestratorName, null, options);

/// <summary>
/// Executes a named sub-orchestrator.
/// </summary>
Expand Down Expand Up @@ -296,11 +324,9 @@ public abstract Task<TResult> CallSubOrchestratorAsync<TResult>(
/// The sub-orchestration failed with an unhandled exception. The details of the failure can be found in the
/// <see cref="TaskFailedException.FailureDetails"/> property.
/// </exception>
public Task CallSubOrchestratorAsync(
public virtual Task CallSubOrchestratorAsync(
TaskName orchestratorName, object? input = null, TaskOptions? options = null)
{
return this.CallSubOrchestratorAsync<object>(orchestratorName, input, options);
}
=> this.CallSubOrchestratorAsync<object>(orchestratorName, input, options);

/// <summary>
/// Restarts the orchestration with a new input and clears its history.
Expand Down
3 changes: 2 additions & 1 deletion src/Abstractions/TaskOrchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public interface ITaskOrchestrator
/// </para>
/// <para>
/// Orchestrators can be scheduled using an external client (see Microsoft.DurableTask.Client). Orchestrators can
/// also invoke child orchestrators using the <see cref="TaskOrchestrationContext.CallSubOrchestratorAsync"/> method.
/// also invoke child orchestrators using the
/// <see cref="TaskOrchestrationContext.CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)"/> method.
/// Orchestrators that derive from <see cref="TaskOrchestrator{TInput, TOutput}"/> can also be invoked using
/// generated extension methods. To participate in code generation, an orchestrator class must be decorated with the
/// <see cref="DurableTaskAttribute"/> attribute. The source generator will then generate a
Expand Down
5 changes: 5 additions & 0 deletions src/Client/Core/DurableTaskClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public virtual Task<string> ScheduleNewOrchestrationInstanceAsync(
TaskName orchestratorName, object? input, CancellationToken cancellation)
=> this.ScheduleNewOrchestrationInstanceAsync(orchestratorName, input, null, cancellation);

/// <inheritdoc cref="ScheduleNewOrchestrationInstanceAsync(TaskName, object, StartOrchestrationOptions, CancellationToken)"/>
public virtual Task<string> ScheduleNewOrchestrationInstanceAsync(
TaskName orchestratorName, StartOrchestrationOptions options, CancellationToken cancellation = default)
=> this.ScheduleNewOrchestrationInstanceAsync(orchestratorName, null, options, cancellation);

/// <summary>
/// Schedules a new orchestration instance for execution.
/// </summary>
Expand Down