This project template illustrates the design pattern for subscription style business logic.
Setup
Run the Temporal Server:
git clone https://github.com/temporalio/docker-compose.git
cd docker-compose
docker-compose upStart
Start the Worker:
go run worker/main.goStart the Workflow Executions:
go run starter/main.goThis will start the Workflow Executions for 5 customers with the following Ids:
Id-0
Id-1
Id-2
Id-3
Id-4
Get billing info
You can Query the Workflow Executions and get the billing information for each customer.
go run querybillinginfo/main.go Run this multiple times to see the billing period number increase during the executions or see the billing cycle cost.
Update billing
You can send a Signal a Workflow Execution to update the billing cycle cost to 300 for all customers.
go run updatechargeamount/main.goCancel subscription
You can send a Signal to all Workflow Executions to cancel the subscription for all customers. Workflow Executions will complete after the currently executing billing period.
go run cancelsubscription/main.goAfter running this, check out the Temporal Web UI and see that all subscription Workflow Executions have a "Completed" status.