Ductwork Documentation
Durable workflows for Ruby
Ductwork is a durable execution workflow orchestration engine and framework. You define a workflow as a series of steps and Ductwork runs them on processes and threads it supervises inside your own application. Every step and state transition is saved to your relational database before Ductwork acts on it, so if a worker, a host, or the database itself goes away mid-flight, the work isn’t lost. It picks back up from the last committed state on its own, without a message broker or anyone having to step in.
What Makes Ductwork Different
Section titled “What Makes Ductwork Different”It runs your workflows for you. Ductwork supervises its own worker and advancer processes alongside your Rails app. You trigger a pipeline and Ductwork claims, executes, and advances each step. There’s no separate scheduler or runtime to stand up.
Your database is the source of truth. Work is stored as rows in your database instead of in-memory messages or a broker queue. Triggering a pipeline writes run, branch, step, and job records. Nothing lives only inside a running process, so a crash can’t lose it.
Automatic recovery from process and host failure. Every worker heartbeats. When one stops, a reaper re-enqueues its in-flight work and a healthy worker picks it up. Fencing tokens and guarded commits stop a “zombie” process that comes back later from overwriting work that already moved on without it.
At-least-once execution. Every step is guaranteed to run, and infrastructure failures (OOM kills, spot reclaims, deploys) never count against a step’s retry budget. Your side of the deal is making steps idempotent, and Ductwork gives you Step#idempotency_key to help with that.
No new infrastructure. You don’t need Kafka, a Temporal server, or a separate worker tier. A Rails app and a relational database are all Ductwork needs.
An Example Workflow
Section titled “An Example Workflow”Each step below is a checkpoint. Ductwork saves a step’s result before moving on, so after a failure the pipeline resumes from the last completed step instead of starting over.
class EnrichAllUsersDataPipeline < Ductwork::Pipeline define do |pipeline| pipeline.start(QueryUsersRequiringEnrichment) # Begin with a single step .expand(to: LoadUserData) # Fan out to process each user .divide(to: [FetchDataFromSourceA, # Split into parallel branches FetchDataFromSourceB]) .combine(into: CollateUserData) # Bring branches back together .chain(to: UpdateUserData) # Sequential processing .divert(to: { success: NotifyUser, # Conditional branching otherwise: FlagForReview }) .converge(into: FinalizeUserRecord) # Merge conditional branches .collapse(into: ReportUserEnrichmentSuccess) # Final aggregation endend
# Trigger from anywhere in your Rails app. Ductwork runs every step to# completion, even if processes or hosts fail along the way.days_outdated = 7EnrichAllUsersDataPipeline.trigger(days_outdated)A step is just a class. Ductwork may re-run a step after a crash, so side effects should be idempotent and return values need to be JSON-serializable. The saved return value is what gets passed to the next step.
class UpdateUserData < Ductwork::Step def initialize(user_data) @user_data = user_data end
def execute # `step.idempotency_key` stays the same across retries and crash re-runs, # so you can use it to make external side effects safe to repeat. ExternalCrm.upsert(@user_data, key: step.idempotency_key)
{ user_id: @user_data["id"], status: "updated" } # saved and passed to the next step endendCore Concepts
Section titled “Core Concepts”- Installation - Install Ductwork and run your first pipeline
- Defining Pipelines - The DSL for connecting steps and managing the flow of work
- Durability - How Ductwork persists, claims, fences, and recovers every unit of work
- Concurrency - Ductwork’s multi-process, multi-threaded execution model
When to Use Ductwork
Section titled “When to Use Ductwork”Ductwork is built for work that spans multiple steps and external systems and has to finish even when deploys and failures get in the way:
- Multi-step integrations - Coordinate calls across services and APIs where a partial failure must resume, not restart
- Data enrichment pipelines - Fetch, transform, and enrich records from multiple sources with durable checkpoints between stages
- ETL processes - Extract, transform, and load with crash recovery instead of re-running the whole batch
- Batch operations - Process large datasets in concurrent chunks where each chunk’s progress is persisted
- Report generation - Aggregate data from multiple sources into a final artifact that only emits once
If your “workflow” is a single background job, a plain job queue is enough. Reach for Ductwork when the work has multiple stages and losing progress is expensive.
Ready to Start?
Section titled “Ready to Start?”Start with the Installation Guide to get your first pipeline running, or read how durability works first.
Have questions? Open an issue on GitHub or upgrade to Pro for custom support.