How nestjs/workflows works
This is a NestJS durable-workflows module. Applications define workflows and use the client to start, signal, inspect, and manage instances; background workers claim instances, replay journaled async execution, and persist progress so runs can survive restarts. The package also provides schedules, timers, retries, compensations, child workflows, lifecycle events, payload codecs, and in-memory, MySQL, and PostgreSQL storage options. The map reflects documented capabilities and indexed references; unsampled implementation details are represented at their enclosing directory where appropriate.
Main entry points: workflow.storage.ts Storage registry · workflow-execution.service.ts Journaled execution · workflow-client.service.ts Workflow client · workflow-worker.service.ts Background worker
Components 22
Workflow API
- Workflow definitions
lib/decorators/workflow.decorator.ts - Workflow client
lib/services/workflow-client.service.ts - Workflow registry
lib/services/workflow-registry.service.ts
Execution runtime
- Background worker
lib/services/workflow-worker.service.ts - Journaled execution
lib/services/workflow-execution.service.ts - Leased worker core
lib/core/workers/leased-worker.ts - Retry policies
lib/core/retries/retry.ts
Persistence
- Storage registry
lib/storage/workflow.storage.ts - Encoded store
lib/storage/encoded-workflow.store.ts - In-memory store
lib/stores/in-memory-workflow.store.ts - MySQL store
lib/mysql/mysql-workflow.store.ts - PostgreSQL store
lib/postgres/postgres-workflow.store.ts - Payload codecs
lib/core/codecs/payload-codecs.ts
Scheduling and events
- Schedule service
lib/services/workflow-schedules.service.ts - Schedule engine
lib/core/scheduling/scheduler.ts - Workflow event routes
lib/cqrs/workflows-cqrs.module.ts - Lifecycle events
lib/events/workflow-events.service.ts
Core utilities
- Clock
lib/core/time/clock.ts - Instance construction
lib/utils/new-instance.util.ts - Duration parsing
lib/core/time/duration.ts - JSON normalization
lib/utils/normalize.util.ts
Other components
- Nest application
Connections 23
- Nest application → Workflow definitions: defines workflows
README.md - Nest application → Workflow client: starts and manages
README.md - Background worker → Journaled execution: runs executions
lib/services/workflow-worker.service.ts - Background worker → Lifecycle events: emits events
lib/services/workflow-worker.service.ts - Background worker → Leased worker core: uses leases
lib/services/workflow-worker.service.ts - Journaled execution → Retry policies: resolves retries
lib/services/workflow-execution.service.ts - Workflow client → Instance construction: constructs instances
lib/services/workflow-client.service.ts - Instance construction → JSON normalization: normalizes input
lib/utils/new-instance.util.ts - Instance construction → Duration parsing: parses timeouts
lib/utils/new-instance.util.ts - Journaled execution → Duration parsing: parses durations
lib/services/workflow-execution.service.ts - Storage registry → Encoded store: wraps store
lib/storage/workflow.storage.ts - Storage registry → In-memory store: defaults to
lib/storage/workflow.storage.ts - Storage registry → Payload codecs: configures codecs
lib/storage/workflow.storage.ts - Encoded store → Payload codecs: encodes payloads
lib/storage/encoded-workflow.store.ts - MySQL store → Storage registry: registers store
lib/mysql/mysql-workflow.store.ts - PostgreSQL store → Storage registry: registers store
lib/postgres/postgres-workflow.store.ts - Schedule service → Schedule engine: uses scheduler
lib/services/workflow-schedules.service.ts - Schedule service → Workflow client: starts scheduled runs
lib/services/workflow-schedules.service.ts - Workflow event routes → Workflow definitions: routes workflow events
- Workflow client → Clock: uses clock
lib/services/workflow-client.service.ts - Journaled execution → Clock: reads time
lib/services/workflow-execution.service.ts - Nest application → MySQL store: may select
README.md - Nest application → PostgreSQL store: may select
README.md