[Feature Request] Divide Workflow stub objects and Workflow proxy objects
I have an idea
I suggest adjusting the Workflow Client interface: introduce a distinction between the concepts of Stub and Proxy.
Currently, as a result of calling the method WorkflowClient::newWorkflowStub($class) (or WorkflowClient::newRunningWorkflowStub($class)), we do not receive a Workflow Stub (WorkflowStubInterface), but a proxy object that redirects calls of Workflow methods related to the Workflow interface. That is, the user interacts with the proxy object as with an implementation of the user's Workflow interface.
At the same time, we have methods WorkflowClient::newUntypedWorkflowStub(), WorkflowClient::newUntypedRunningWorkflowStub(), which return the very WorkflowStubInterface (type-level guarantee). That is, they work as expected.
[!NOTE]
WorkflowStubInterfaceis convenient when, for example, you need to call the Describe method or the Update method with your own WaitPolicy.
We face two problems:
- methods with the
Stubpostfix work differently: two out of four returnWorkflowStubInterface, the other two return a proxy. - there is no proper way to get
WorkflowStubInterfacefrom a Workflow class. Both methods that accept a class return us a proxy.
In this commit, you can see changes in the WorkflowClientInterface interface.
https://github.com/temporalio/sdk-php/commit/1847f723ff5ece0320dccfc30312da387c032b96
In the methods that currently return a Proxy, I've considered backward compatibility through the $proxy parameter. This will all be cleaned up in the next major version.
Calls to create stubs with $proxy=true will throw deprecation notices.
We can also discuss replacing the naming of Stub with Handle. Then we'll just make all the *Stub methods deprecated :)
@Sushisource, I propose to introduce new methods instead. Can we hop on a call to discuss it?
New methods might be:
// Return WorkflowStubInterface
$wfClient->newWorkflow($class, ...);
$wfClient->newRunningWorkflow($class, ...);
// Return Proxy objects. There is `Proxy` suffix
$wfClient->newWorkflowProxy($class, ...);
$wfClient->newRunningWorkflowProxy($class, ...);
// Untyped (unknown class name). Return WorkflowStubInterface
$wfClient->newUntypedWorkflow($type, ...);
$wfClient->newUntypedRunningWorkflow($type, ...);
// DEPRECATED
$wfClient->newWorkflowStub($class, ...); // Proxy object
$wfClient->newRunningWorkflowStub($class, ...); // Proxy object
$wfClient->newUntypedWorkflowStub($type, ...); // WorkflowStubInterface
$wfClient->newUntypedRunningWorkflowStub($type, ...); // WorkflowStubInterface