The purpose of the repo is to demonstrate the EnableEagerStart
and Update features of Temporal simultaneously.
The example is a simplified personal payments system, Think Venmo. This example has two parts, a user can (1) request payment from another user, and (2) the recipient can accept or decline.
The Update feature is used for the latter step, and the workflow is started with EnableEagerStart
to improve startup time for the initial request.
- Docker Desktop
- Temporal Cloud Certificate
- Copy the cert into
./certs/bitovi.crt
- Copy the key into
./certs/bitovi.key
- Copy the cert into
docker compose up --build -d
docker compose down -v
docker compose logs worker -f
Create a payment request
Eagerly start a workflow to request money from another user. It will immediately create a payment request entity, notify the target user, and wait for an update from a user response.
curl --location 'http://0.0.0.0:8080/payment-request' \
--header 'Content-Type: application/json' \
--data '{
"userId": "usr_0dc9d91f-f102-47ca-9e47-bcd75babfe20",
"amount": 20.99
}'
{
"paymentRequestId": "req_8eb7d5a2-4ac4-4b93-b8ce-ce7809ab8a04"
}
Accept a payment request
Accept a payment by using an update call on the running workflow and passing in the accepted status from the user response.
curl --location 'http://localhost:8080/payment-response' \
--header 'Content-Type: application/json' \
--data '{
"accepted": true,
"paymentRequestId": "req_8eb7d5a2-4ac4-4b93-b8ce-ce7809ab8a04"
}'
{
"paymentId": "pay_3903ed76-cfd2-4d9b-a4bc-2fc2f6d8254b"
}