This is a demo to show how temporal could be used to orchestrate a food delivery's actors - restaurant, courier, and the order
Install docker
- Build courier service:
./gradlew :courier:jibDockerBuild
- Build restaurant service:
./gradlew :restaurant:jibDockerBuild
- Build issuance service:
./gradlew :issuance:jibDockerBuild
- Run full stack including temporal:
docker-compose up
- Go to issuance service on
http://localhost:8082/graphiql
, and enter the graph query to create an order:
mutation {
fulfillOrder(order: { id: "my-test-order-id-1"}) {
id
}
}
-
Observe issuance logs has some entry
-
Observe in temporal UI on
http://localhost:8088/namespaces/default/workflows?range=last-1-days
that a workflow is started. Copy the workflow id you see forRestaurantOrderWorkflow
. -
Go to restaurant service on
http://localhost:8081/graphiql
, and enter the graph query to make restaurant accept order:
mutation {
acceptOrder(order: { id: "<restaurant_order_workflow_id_from_earlier>"}) {
id,
status
}
}
-
Observe restaurant logs has some entry
-
Observe in temporal UI on
http://localhost:8088/namespaces/default/workflows?range=last-1-days
that a newCourierOrderWorkflow
is started. Copy the workflow id you see forCourierOrderWorkflow
. -
Go to restaurant service on
http://localhost:8083/graphiql
, and enter the graph query to make courier accept order:
mutation {
courierAcceptOrder(order: { id: "<courier_order_workflow_id_from_earlier>"}) {
id,
status
}
}
-
Observe courier logs has some entry
-
Temporal UI should show master workflow (
IssuanceWorkflow
) and child workflows (CourierOrderWorkflow
andRestaurantOrderWorkflow
) are now completed
- Kill the service in docker, for example
courier
:
docker-compose stop courier
- Run application manually outside docker:
./gradlew :courier:bootRun
The local setup is using grafana for data visualizaton and prometheus for data collection. In production, we will most likely use DataDog / AWS Cloudwatch Metrics.
Temporal allows customization of metrics endpoints. For this example, we configured temporal's PROMETHEUS_ENDPOINT
. See the docker-compose.yml file for more details.
After that, the stats can be monitored on localhost:3000
.
-
Install k6
-
Go to
loadtest/
and runk6 run loadtest.js
. You may edit the code as you wish