Skip to content
Open
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
45 changes: 44 additions & 1 deletion src/Temporalio/Client/ITemporalClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,49 @@ public static async Task<TResult> ExecuteWorkflowAsync<TWorkflow, TResult>(
return await handle.GetResultAsync(rpcOptions: options.Rpc).ConfigureAwait(false);
}

/// <summary>
/// Signal and (optionally) start a workflow via lambda invoking the signalWithStart method.
/// </summary>
/// <typeparam name="TWorkflow">Workflow class type.</typeparam>
/// <param name="client">Client to use.</param>
/// <param name="workflowRunCall">Invocation of workflow run method with a result.</param>
/// <param name="signalCall">Invocation of signal method without a result.</param>
/// <param name="options">Start workflow options. ID and TaskQueue are required.</param>
/// <returns>Workflow handle for the started workflow.</returns>
/// <exception cref="ArgumentException">Invalid run call or options.</exception>
/// <exception cref="Exceptions.RpcException">Server-side error.</exception>
public static async Task<WorkflowHandle<TWorkflow>> SignalWorkflowWithStartAsync<TWorkflow>(
this ITemporalClient client,
Expression<Func<TWorkflow, Task>> workflowRunCall,
Expression<Func<TWorkflow, Task>> signalCall,
WorkflowOptions options)
{
options.SignalWithStart(signalCall);
return await client.StartWorkflowAsync(workflowRunCall, options).ConfigureAwait(false);
}

/// <summary>
/// Signal and (optionally) start a workflow via lambda invoking the signalWithStart method.
/// </summary>
/// <typeparam name="TWorkflow">Workflow class type.</typeparam>
/// <typeparam name="TResult">Workflow result type.</typeparam>
/// <param name="client">Client to use.</param>
/// <param name="workflowRunCall">Invocation of workflow run method with a result.</param>
/// <param name="signalCall">Invocation of signal method without a result.</param>
/// <param name="options">Start workflow options. ID and TaskQueue are required.</param>
/// <returns>Workflow handle for the started workflow.</returns>
/// <exception cref="ArgumentException">Invalid run call or options.</exception>
/// <exception cref="Exceptions.RpcException">Server-side error.</exception>
public static async Task<WorkflowHandle<TWorkflow, TResult>> SignalWorkflowWithStartAsync<TWorkflow, TResult>(
this ITemporalClient client,
Expression<Func<TWorkflow, Task<TResult>>> workflowRunCall,
Expression<Func<TWorkflow, Task>> signalCall,
WorkflowOptions options)
{
options.SignalWithStart(signalCall);
return await client.StartWorkflowAsync(workflowRunCall, options).ConfigureAwait(false);
}

/// <summary>
/// Shortcut for
/// <see cref="ITemporalClient.StartWorkflowAsync{T}(Expression{Func{T, Task}}, WorkflowOptions)" />
Expand Down Expand Up @@ -158,4 +201,4 @@ public static async IAsyncEnumerable<WorkflowHistory> ListWorkflowHistoriesAsync
}
#endif
}
}
}