temporalio / sdk-dotnet

Temporal .NET SDK
MIT License
375 stars 30 forks source link

Add strongly-typed extension methods for SignalWithStart #269

Open Blackburn29 opened 3 months ago

Blackburn29 commented 3 months ago

What was changed

Added extension methods for calling signalWithStart.

Why?

Adds support for strong typings when starting a workflow with a signal.

Currently this requires holding a second variable for WorkflowOptions and calling options.SignalWithStart(x => x.Method()).

These extension methods give you the ability to short-hand the setup:

var handle = await _temporalClient.SignalWorkflowWithStartAsync(
    workflow => workflow.RunAsync(),
    workflow => workflow.SignalMethod(),
    new WorkflowOptions
    {
       //...
    });

Checklist

  1. Closes N/A

  2. How was this tested: I have been using these extension methods in some of my applications for awhile, but I figured they would be useful to others.

  3. Any docs updates needed? N/A

CLAassistant commented 3 months ago

CLA assistant check
All committers have signed the CLA.

cretz commented 3 months ago

We may have future things like update with start and so we decided in newer SDKs that extra things on start are just options, so I am not sure we want to provide top-level shortcuts to save creating options in this case, but we of course support users doing so like you've done here.

As potential new multi-operation RPC calls come about some of this design may change. But if they don't change this much, we can merge this shortcut. But I think we want to wait on it to see those designs.