Skip to main content

47 docs tagged with "Design Patterns"

View all tags

Activity Dependency Injection

Injects external dependencies into Activities at Worker startup, keeping Workflow code deterministic and Activities testable.

Approval Pattern

Human-in-the-loop Workflows that block until external approval decisions are made. Uses Signals to capture approval data with metadata.

Batch Iterator

Pages through unbounded datasets using Continue-As-New to prevent history overflow while maintaining exactly-once processing guarantees.

Batch Processing Patterns

Compare Fan-Out, Batch Iterator, Sliding Window, and MapReduce Tree patterns for processing large record sets reliably at scale.

Child Workflows Pattern

Decomposes complex Workflows into smaller, reusable units. Each child has an independent Workflow ID, history, and lifecycle.

Continue-As-New Pattern

Prevents unbounded history growth by completing the current execution and starting a new one with fresh history.

Delayed Callback (Webhooks)

Webhooks become durable: inbound calls arrive as Signals, outbound calls fire after a durable sleep, and Activities complete later via task tokens.

Delayed Retry

Override one failure's retry interval with nextRetryDelay on ApplicationFailure, matching the wait time the error reports.

Delayed Start Pattern

Creates Workflows immediately but defers execution until a specified delay expires. Fits one-time scheduled operations and grace periods.

Downstream Rate Limiting

Rate-limits calls to a downstream service by routing throttled Activities to a dedicated Task Queue with a server-enforced throughput cap.

Eager Workflow Start

Eager Workflow Start sends the first Workflow Task directly to a co-located Worker, skipping the Matching Service to cut startup latency.

Early Return (Update with Start)

Synchronous initialization with asynchronous completion. Returns results immediately while processing continues in the background.

Early Return + Local Activities

Extends Early Return by running Phase 1 as Local Activities, so the client's first response comes from in-process work, not a server call.

Entity & Lifecycle Patterns

Pattern selection guide for modeling long-lived stateful entities and managing Workflow history growth over time.

Entity Workflow Pattern

A long-lived business entity — a user account, device, or order — gets one Workflow per instance, with Signals and Updates driving every state transition.

Error Handling & Retry Patterns

Pattern selection guide and decision tree for choosing the right retry strategy based on your error type, cost constraints, and recovery requirements.

Event Accumulator Pattern

Durably collect and deduplicate signals from multiple senders, then process the batch after a sliding inactivity timeout.

External Interaction Patterns

Compares five patterns for waiting on external systems and human decisions: polling, heartbeating Activities, delayed start, webhooks, and approval.

Fairness

Distributes Worker capacity evenly across tenants or users so that a burst from one caller does not starve the others.

Fan-Out with Child Workflows

Distributes a large record set across parallel Child Workflows for concurrent processing with automatic scaling.

Fast/Slow Retries

Retry fast with a short interval first, then shift to a slow, unlimited interval so the Workflow outlasts an extended downstream outage.

Fixed Count of Retries

Cap the number of Activity retry attempts to control cost when each attempt consumes a paid or limited resource.

Fixed Wall-Time Retries

Bound the total elapsed time across all retry attempts to enforce a business SLA, regardless of how many individual attempts occur.

Local Activities

Local Activities run inside the Worker process, skipping server round-trips for short, idempotent Activities on a latency-sensitive path.

MapReduce Tree

Recursively splits a dataset into a binary tree of Child Workflows, processes leaves in parallel, then aggregates results back up the tree.

Non-Retryable Errors

Mark error types that will never succeed — such as validation failures or missing records — so Temporal fails fast instead of retrying indefinitely.

Parallel Execution

Executes multiple Activities concurrently for maximum throughput with error handling and controlled parallelism.

Performance & Latency Patterns

Pattern selection guide for reducing Workflow latency, with a comparison of the round-trips each pattern removes and their combined effect.

Pick First Pattern

Races multiple Activities in parallel, returns the first completed result, and cancels the remaining Activities using SDK cancellation scopes.

Polling External Services

Strategies for polling external resources with varying frequencies: frequent, infrequent, and periodic patterns.

Priority Task Queues

Assigns a priority level to Workflows and Activities so that time-sensitive work executes ahead of lower-priority work within a single Task Queue.

QoS & Throughput Patterns

Pattern selection guide for controlling execution rate, protecting downstream services from overload, and ensuring fair capacity distribution across tenants.

Request-Response via Updates

Uses a Workflow Update to validate a request, modify Workflow state, and return a typed result to the caller synchronously, with strong consistency.

Retry Alerting via Metrics

Emit a metric from the Activity when attempts cross a threshold, so on-call teams see persistent failures before an SLA breach.

Saga Pattern

Manages distributed transactions with compensating actions. Each step has a compensation that undoes its effects if subsequent steps fail.

Signal with Start Pattern

Starts a Workflow when Signaling it if it does not already exist. If already running, it receives the Signal directly.

Sliding Window

Maintains a fixed number of concurrently active Child Workflows, starting a new one each time an existing one completes.

Task Orchestration Patterns

Compares Child Workflows, Parallel Execution, and Pick First (Race) for decomposing, running concurrently, and racing work inside a single Workflow.

Temporal Design Patterns

A catalog of common, reusable, and proven design patterns for Temporal Workflows, organized by problem domain.

Worker Configuration Patterns

Pattern selection guide for configuring how Workers are set up, how work is routed, and how Activities access external dependencies.

Workflow Messaging Patterns

Pattern selection guide for sending data into running Workflows and receiving responses or triggering behavior changes.