Hello. I am new to temporal and currently i’m working on creating a grpc request-handler in which I create a long workflow and trying to retrieve an information from there in order to respond to user’s grpc request whilst workflow execution continues. To be short, here is the usecase:
User sends a GRPC request
Send request to service A
Get response from service A
Some business logic
Save information in Database
Respond to user’s GRPC request
Await an http callback from service A
I see the solution of this problem like following:
GRPC Handler
Workflow
Accept GRPC request
ExecuteWorkflow()
QueryWorkflow(“getGRPCResponse”) in loop until retrieve a response
So how is this approach different from queries? Because I register the update handler at the beginning of the workflow, the UpdateWorkflow method returns the result immediately. The only way to achieve “blocking” behavior is to use a go channel to write response to, when the response is ready. But, if I’m right, this is considered as non-deterministic.
Queries cannot block and cannot mutate the workflow state.
Update handler can block and can mutate workflow state. You can achieve blocking semantic using Temporal equivalent of Go channel as well as Future or Await condition.