Demos various aspects of Temporal using the Typescript SDK.
https://transfer.tmprl-demo.cloud/
A Java SDK version of this example is also available.
(optional if using local Temporal dev server)
server/contains.env_example. Copy it to.env.developmentand change settings to match your temporal installation.STRIPE_SECRET_KEYis optional (use if you want to run simulated charges against the Stripe API)ui/contains.env_example. Copy it to.env.developmentand change settings to point to your API (server) location (default is / which should be fine)- The server respects .env.production if NODE_ENV is "production" (and the Svelte app is built using npm run build such as in the Dockerfile)
Run a Temporal Server (Guide)
brew install temporaltemporal server start-dev(Temporal Server web UI: localhost:8233)
Install Node dependencies:
-
cd server/ -
npm install -
cd ui/ -
npm install
Run workers
- Run a workflow worker:
cd servernpm run worker
Run API and Web UI (localhost:3000)
nodemon /server/index.ts(from the project root directory)
A dropdown menu simulates the following scenarios
- The transfer will run to completion
The transfer will pause and wait for approval. If the user doesn't approve the transfer within a set time, the workflow will fail.
Approve a transfer using Signals
You can also do this through the temporal cli:
temporal workflow signal \
--query 'ExecutionStatus="Running" and WorkflowType="moneyTransferWorkflow"' \
--name approveTransfer \
--reason 'approving transfer'Approve a transfer using Updates (COMING SOON)
You can do this through the temporal cli:
temporal workflow update \
--env prod \
--workflow-id TRANSFER-XXX-XXX \
--name approveTransferUpdateThe workflow's Update function has a validator. It will reject an Update if:
- The transfer isn't waiting for approval
- The transfer has already been approved
In ./server/temporal/workflows.ts, uncomment the line // throw new Error('Workflow bug!');. Re-comment it and restart the worker for the workflow to recover.
Will introduce artifical delays in the withdraw activity's API calls. This will cause activity retries. After 5 retries, the delay will be removed and the workflow will proceed.
Introduces an unrecoverable failure in the deposit activity (invalid account). The workflow will fail after running compensation activities (undoWithdraw).
Creates a Schedule that will run a set of workflows on a cadence.
Produces a schedule ID, which you can inspect in the Temporal UI's "Schedules" menu.
Set ENCRYPT_PAYLOADS to "true" in the configuration file (see Configuration section above).
You can decrypt these payloads in Temporal Cloud's UI/cli using the codec server: https://codec.tmprl-demo.cloud (source). Ensure you switch on "Pass the user access token with your endpoint" setting in the Codec Configuration in Temporal Cloud. Note: The codec server is only compatible with workflows running in Temporal Cloud.
temporal workflow list --env prod -q 'ExecutionStatus="Failed" OR ExecutionStatus="Terminated"'
(Advanced) Debug/replay Workflow histories with the Temporal VSCode Extension
- Open /server as a VSCode project
- Run the replayer on a downloaded workflow JSON file