Hello,
I wonder what the best practice for the following situation is: I have a user registration workflow with two activities.
- It inserts the user into the database
- It sends an email to the user
The workflow is executed from a REST API endpoint. I would like the REST API to wait until the user has been inserted into the database or a timeout is reached before responding. Otherwise, the user would receive a success message even though only the workflow has been created and not the actual user.
I have the following ideas and wonder what the best practice is:
- After the user has been inserted into the database, create an abandoned child workflow. That way I can await the parent workflow’s result.
- Implement a separate activity that notifies the REST API.
- Send an update immediately after the workflow has been created and ensure that the update handler in the workflow only responds after the first activity has completed or a timeout, cancellation or failure occurs. Though, I am not completely sure what an implementation would look like:
3.1. Can an update handler block the workflow execution? Is the update handler executed in a separate goroutine?
3.2. Is the update guaranteed to be sent to the same worker?
3.3. How do I have to handle workflow timeouts, cancellations and failures inside the update handler that is waiting for the database activity to complete?