Example order process workflow using Temporal
The workflow proceeds as follows:
- Workflow begins with an order.
- The inventory is checked (if the check fails, then the workflow is failed).
- The payment is processed.
- The goods are "shipped".
- The customer is notified via email.
If the workflow fails, a notification that the order cannot be processed is sent. If payment has been made it is reversed.
The code is under lib.
The workflow is in workflow.rb.
A client and a worker for the workflow are included.
The activities are under lib/activities.
The activities call an "interface" layer which represents the API(s) for the target systems if this was real world.
The data model is under lib/model.
- Clone the repository.
cdto theorder-process-workflowdirectory.- Ensure temporal is running (e.g.
temporal server start-dev). - In one terminal session start the worker:
bundle exec ruby lib/worker.rb. - In another terminal session start the client:
bundle exec ruby lib/client.rb.
-
Ruby 3.4.9
-
Temporal 1.8.1
-
Fedora 44 (on WSL)