pvsone / typescript-money-transfer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Money Transfer Example

Forked from https://github.com/steveandroulakis/temporal-money-transfer

Run a Temporal Server (Guide)

brew install temporal
temporal server start-dev

Install Node dependencies:

cd ui
npm install

cd server
npm install

Start worker

cd server
npm run worker

Start UI

cd server
npm run start

Demo various failures and recoveries

A dropdown menu simulates the following scenarios

Happy Path

  • The transfer will run to completion

Require Human-In-Loop Approval

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'

Simulate a Bug in the Workflow (recoverable failure)

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.

Simulate API Downtime (recover on 5th attempt)

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.

Invalid Account (unrecoverable failure)

Introduces an unrecoverable failure in the deposit activity (invalid account). The workflow will fail after running compensation activities (undoWithdraw).

Schedule a recurring transfer

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.

About


Languages

Language:TypeScript 49.0%Language:Svelte 34.9%Language:JavaScript 11.4%Language:HTML 2.4%Language:CSS 1.8%Language:Dockerfile 0.6%