From f3a74b2aeaee6089c23fb8f43f9c8e565904f1e4 Mon Sep 17 00:00:00 2001 From: Blake LaFleur Date: Fri, 7 Jun 2024 11:05:19 -0500 Subject: [PATCH] Add strongly-typed extension method for SignalWithStart --- .../Client/ITemporalClientExtensions.cs | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/Temporalio/Client/ITemporalClientExtensions.cs b/src/Temporalio/Client/ITemporalClientExtensions.cs index 2beb2d26..b1c6a91e 100644 --- a/src/Temporalio/Client/ITemporalClientExtensions.cs +++ b/src/Temporalio/Client/ITemporalClientExtensions.cs @@ -43,6 +43,49 @@ public static async Task ExecuteWorkflowAsync( return await handle.GetResultAsync(rpcOptions: options.Rpc).ConfigureAwait(false); } + /// + /// Signal and (optionally) start a workflow via lambda invoking the signalWithStart method. + /// + /// Workflow class type. + /// Client to use. + /// Invocation of workflow run method with a result. + /// Invocation of signal method without a result. + /// Start workflow options. ID and TaskQueue are required. + /// Workflow handle for the started workflow. + /// Invalid run call or options. + /// Server-side error. + public static async Task> SignalWorkflowWithStartAsync( + this ITemporalClient client, + Expression> workflowRunCall, + Expression> signalCall, + WorkflowOptions options) + { + options.SignalWithStart(signalCall); + return await client.StartWorkflowAsync(workflowRunCall, options).ConfigureAwait(false); + } + + /// + /// Signal and (optionally) start a workflow via lambda invoking the signalWithStart method. + /// + /// Workflow class type. + /// Workflow result type. + /// Client to use. + /// Invocation of workflow run method with a result. + /// Invocation of signal method without a result. + /// Start workflow options. ID and TaskQueue are required. + /// Workflow handle for the started workflow. + /// Invalid run call or options. + /// Server-side error. + public static async Task> SignalWorkflowWithStartAsync( + this ITemporalClient client, + Expression>> workflowRunCall, + Expression> signalCall, + WorkflowOptions options) + { + options.SignalWithStart(signalCall); + return await client.StartWorkflowAsync(workflowRunCall, options).ConfigureAwait(false); + } + /// /// Shortcut for /// @@ -158,4 +201,4 @@ public static async IAsyncEnumerable ListWorkflowHistoriesAsync } #endif } -} \ No newline at end of file +}