Long-Running Processes
Long-running processes are workflows that execute over extended time periods — from hours to days to weeks — while maintaining full reliability and consistency. Orcher's durable timers let you sleep for days without consuming resources, pause for human approvals with automatic timeout and escalation, schedule future actions at precise intervals, and maintain workflow state across restarts and failures. These patterns are ideal whenever you need to wait for external events (human approvals, webhook callbacks, partner responses), schedule future actions (send a reminder in 24 hours, expire a trial in 7 days), implement timeouts (wait for payment confirmation with a 30-minute deadline), coordinate multi-day processes (order fulfillment, employee onboarding, loan approval), or handle recurring tasks (daily reports, weekly cleanups, monthly billing). Because sleeping workflows consume almost no resources, you can run thousands of concurrent long-running workflows with minimal overhead.
Create accountProvision resourcesSend welcome emailOnboarding guideCheck engagementQuery usage metricsSend midpoint emailTips & best practicesTrial expiredUpgraded? → extend : → downgradeDurable Timers
Durable timers let your workflow sleep for extended periods — hours, days, or even weeks — without consuming any resources. The timer is persisted to the journal, so it survives server restarts, deployments, and failures. When the timer fires, the workflow resumes exactly where it left off.
1use orcher::prelude::*;2use anyhow::Result;3use std::time::Duration;4use serde::{Deserialize, Serialize};56#[derive(Debug, Clone, Serialize, Deserialize)]7struct ReminderInput {8 user_id: String,9 message: String,10 delay_hours: u64,11}1213#[derive(Debug, Clone, Serialize, Deserialize)]14struct ReminderResult {15 user_id: String,16 sent: bool,17 sent_at: String,18}1920#[task]21async fn send_email_reminder(input: ReminderInput) -> Result<()> {22 // Send the email reminder23 Ok(())24}2526#[task]27async fn send_reminder(message: String) -> Result<()> {28 // Send a reminder message29 Ok(())30}3132// Send a reminder after a delay33#[workflow(name = "delayed_reminder", version = "1.0.0")]34pub async fn delayed_reminder(35 ctx: WorkflowContext,36 input: ReminderInput,37) -> Result<ReminderResult> {38 println!("Reminder scheduled for {} in {} hours",39 input.user_id, input.delay_hours);4041 // Sleep for the specified duration (durable - survives restarts)42 ctx.sleep(Duration::from_secs(input.delay_hours * 3600)).await?;4344 println!("Timer fired - sending reminder to {}", input.user_id);4546 // Send the reminder47 ctx.execute_task(send_email_reminder, input.clone()).await?;4849 Ok(ReminderResult {50 user_id: input.user_id,51 sent: true,52 sent_at: chrono::Utc::now().to_rfc3339(),53 })54}5556// Multiple reminders at different intervals57#[workflow(name = "multi_reminder", version = "1.0.0")]58pub async fn multi_reminder(59 ctx: WorkflowContext,60 user_id: String,61) -> Result<()> {62 // Send reminder after 1 day63 ctx.sleep(Duration::from_secs(86400)).await?;64 ctx.execute_task(send_reminder, "Day 1 reminder".to_string()).await?;6566 // Send reminder after 3 days (additional 2 days)67 ctx.sleep(Duration::from_secs(172800)).await?;68 ctx.execute_task(send_reminder, "Day 3 reminder".to_string()).await?;6970 // Send reminder after 7 days (additional 4 days)71 ctx.sleep(Duration::from_secs(345600)).await?;72 ctx.execute_task(send_reminder, "Day 7 reminder".to_string()).await?;7374 println!("All reminders sent for user {}", user_id);75 Ok(())76}Next Steps
Human-in-the-Loop Approvals
Pause workflows for human decisions with timeout and escalation.
Trial Period Management
Manage SaaS trial periods with milestone reminders.
Order Fulfillment Process
Multi-day order processing with stage tracking.
Recurring Tasks
Schedule repeating operations with conditional logic.
Best Practices & Performance
Guidelines for production long-running workflows.