This repository demonstrates common Temporal.io design patterns deployed using HotMesh. Each example pattern is authored as a set of unit tests with assertions made against the runtime.
Although the APIs are the same, HotMesh is serverless and uses decentralized message routers. The backend is pluggable and interchangeably supports Postgres, Redis, and NATS. NATS is useful for event-heavy workflows and can be added alongside Postgres for a hybrid backend. Publish events directly from running workflows for real-time insights. Redis is ideal for high-throughput workflows and can be run durably with AOF persistence (without clustering).
Temporal | HotMesh |
---|---|
![]() |
![]() |
- Clone the Repository
git clone https://github.com/hotmeshio/temporal-patterns-typescript.git cd temporal-patterns-typescript
- Install the dependencies
npm install
- Startup Docker
npm run docker:up
- Shutdown Docker
npm run docker:down
- Cleanup Docker
npm run docker:reset
- Run Unit Tests from within Docker (Postgres is the default backend).
npm test
- Run a Single Test (e.g., collation)
npm run test:collation
- Collation: Demonstrates
Promise.all
behavior in a reentrant workflow. - Composition: Highlights parent-child workflow interactions.
- Error (Unknown): Handles unexpected errors in workflows with resilience strategies.
- Error (Fatal): Highlights workflows with unrecoverable errors.
- Everything: A comprehensive test case combining multiple patterns, including:
hook
,signal
,search
,sleep
andinterrupt
. - Transactional Hook: Implements a hook mechanism for transactional workflow subprocess execution.
- Idempotency: Ensures idempotent behavior in workflows for replay safety.
- Interrupt: Demonstrates cancelling a running workflow based on external events.
- Random: Deterministically generates random numbers in workflows appropriate for replay.
- Retry: Shows retry configurability and strategies for handling transient errors (like a flaky endpoint).
- Search: Integrates search capabilities within workflows to read and write user data idempotently.
- Signal: Uses signaling to awaken paused workflows from external and internal inputs.
- Sleep: Demonstrates internally-triggered delays in workflow execution along with externally-triggered interruptions.
Visit each pattern’s page to see example code and unit test cases in action.
- SDK Documentation: Detailed documentation and examples of each pattern.
- Download (NPM): Access the HotMesh package on npm.
The examples in this project are licensed under the Apache 2.0 License. See the LICENSE file for more details.
Contributions are welcome! Please follow the contribution guidelines to submit pull requests or open issues.
This project is not affiliated with, endorsed by, or sponsored by Temporal Technologies, Inc. Temporal is a trademark of Temporal Technologies, Inc., and all references to Temporal and related technologies are for educational and demonstration purposes only.