Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 2.12 KB

README.md

File metadata and controls

54 lines (39 loc) · 2.12 KB

Temporal Demo: Order Fulfillment in Typescript

Overview

A Temporal workflow for a sample e-commerce order fulfillment use case. This demo showcases Temporal's powerful durability and interactive capabilities.

Watch the demo (YouTube)

Watch the demo

Running this sample

The sample is configured by default to connect to a local Temporal Server running on localhost:7233

temporal server start-dev

To instead connect to Temporal Cloud, set the following environment variables, replacing them with your own Temporal Cloud credentials.

With mTLS:

TEMPORAL_ADDRESS=testnamespace.sdvdw.tmprl.cloud:7233
TEMPORAL_NAMESPACE=testnamespace.sdvdw
TEMPORAL_CLIENT_CERT_PATH="/path/to/file.pem"
TEMPORAL_CLIENT_KEY_PATH="/path/to/file.key"

With API key:

TEMPORAL_ADDRESS=us-west-2.aws.api.temporal.io:7233
TEMPORAL_NAMESPACE=testnamespace.sdvdw
TEMPORAL_API_KEY="your-api-key"
# ensure TEMPORAL_CLIENT_CERT_PATH and TEMPORAL_CLIENT_KEY_PATH are not set

npm install to install dependencies.

Run npm run start to start the Worker. (You can also get Nodemon to watch for changes and restart the worker automatically by running npm run start.watch.) Run npm run workflow to run the Workflow.

Scenarios

See demo folder for different scenarios that will be live-coded into workflows.ts:

  1. Happy path (demo/workflows1.ts)
  2. API Downtime (uncomment inventory code)
  3. Invalid order troubleshooting, set cc expiry in starter.ts to 12/23
  4. Human in the loop, send approveOrder signal (demo/workflows2.ts)
  5. Approve or expire order (demo/workflows3.ts)
  6. Bug in workflow, add throw Error('workflow bug!') in workflow code
  7. Generate invalid orders npm run workflow -- --numOrders 50 --invalidPercentage 20 (note the -- to pass args to the script)
    • This will generate 50 orders with 20% invalid orders
    • Uncomment bug fix in api.ts and run again to fix workflows