temporalio / sdk-java

Temporal Java SDK
https://temporal.io
Apache License 2.0
221 stars 147 forks source link

Improve signalWithStart usability #915

Open Spikhalskiy opened 2 years ago

Spikhalskiy commented 2 years ago

Workflow#signalWithStart method interface is overcomplicated and hard to use without checking with samples first. We should improve the classes structure and provide more conventional builders and factory methods around this method and functionality.

mfateev commented 2 years ago

Such refactoring should keep the strongly typed way to call this method the current implementation provides.

tsurdilo commented 2 years ago

Wanted to suggest one possible improvement. Currently with signalWithStart we can do for example:

WorkflowStub untyped = WorkflowStub.fromTyped(typedStub);
untyped.signalWithStart(...);

( or just create an untyped stub to start with ) so this works off just WorkflowStub (untyped)

WorkflowClient.signalWithStart only works off typed stubs, for example:

 BatchRequest request = client.newSignalWithStartRequest();
 request.add(myWorkflowStub::exec, input); // exec is workflow method
 request.add(myWorkflowStub::handleSignal, signalData); // handleSignal is a signal method
 client.signalWithStart(request);

It would be nice to add an "untyped" option for WorkflowClient.signalWithStart that takes in signalName, signalData, inputData.

Bonus question, whats the use for WorkflowClient.signalWithStart? When would you use it instead of WorkflowStub.signalWithStart?

drewhoskins-temporal commented 1 month ago

We've recently shipped updateWithStart in pre-release, and we hope it has better usability. If it goes well, we'd like to make signalWithStart adopt this pattern for better usability and consistency, so please take a look.