Skip to content

hotmeshio/temporal-patterns-typescript

Repository files navigation

Temporal Patterns

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

Getting Started

Requirements

Installation

  1. Clone the Repository
    git clone https://github.com/hotmeshio/temporal-patterns-typescript.git
    cd temporal-patterns-typescript
  2. Install the dependencies
    npm install
  3. Startup Docker
    npm run docker:up
  4. Shutdown Docker
    npm run docker:down
  5. Cleanup Docker
    npm run docker:reset
  6. Run Unit Tests from within Docker (Postgres is the default backend).
    npm test
  7. Run a Single Test (e.g., collation)
    npm run test:collation

Pattern List

  • 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 and interrupt.
  • 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.

Additional Resources

License

The examples in this project are licensed under the Apache 2.0 License. See the LICENSE file for more details.

Contributing

Contributions are welcome! Please follow the contribution guidelines to submit pull requests or open issues.

Disclaimer

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.

About

Temporal pattern examples

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published