REST API on top of Temporal

Have a REST API, with a number of backend services. HTTP requests are routed to controllers, which in turn calls backend micro-services using grpc. Services use Mysql to save state. Want to use Temporal to orchestrate several multi-step flows here.

How does one get data from a HTTP request into a workflow. Can use signals, but how does the response go back to the same HTTP request. How does the HTTP request/response paradigm fit in with Temporal?

Appreciate if you could point to some code in Go.

Thanks.

How does one get data from a HTTP request into a workflow.

You can pass the payload as workflow input or as signal data as you mention (it should serializable by default or your custom data converter). You can also use SignalWithStartWorkflow.

but how does the response go back to the same HTTP request

Trying to figure out what result you need to return? Is it workflow execution result or a current state of a running/completed execution?
Temporal guarantees read after write consistency of signal and then query. So can send a signal and then query the workflow state.

1 Like

I think this is a correct way to attack the scenario. Just my two cents, thinking about it:

  1. If the workflow reuse policy is not “REJECT DUPLICATE” then go to 2, otherwise response with HTTP 400 (or similar)
  2. I will use a nomenclature to generate Workflows Id’s such as “busionessUnit-process-timestamp” and persist this in my database
  3. If the scenario is sync, use signal/queries to retrieve the result. If the scenario is async, just return the Workflow ID generated with HTTP 200 and say to your client “hey, with this ID you can get later the results”.

Maybe I’m crazy, but I like this approach