Skip to main content

Crate qail_workflow

Crate qail_workflow 

Source
Expand description

§QAIL Flow Engine

Declarative state machine engine for multi-vertical workflows.

Provides domain-agnostic primitives for orchestrating sequences of database queries, notifications, and external events. Designed for booking recovery, inventory sync, and operator coordination across ferry, car rental, yacht charter, and fishing boat verticals.

§Architecture

your app (domain states + executor impl)
      ↓
qail-workflow (Flow Engine)
      ↓
qail-core (AST queries composed into steps)
      ↓
optional qail-workflow-postgres (Flow Ledger)

§Quick Start

ⓘ
use qail_workflow::*;
use qail_core::Qail;

// Define a workflow
let wf = WorkflowDefinition::new("booking_recovery")
    .initial_state("operator_declined")
    .transition("operator_declined", "recovery_mode", vec![
        WorkflowStep::query(
            Qail::get("odysseys").limit(5),
            Some("alternatives"),
        ),
        WorkflowStep::for_each("alternatives", vec![
            WorkflowStep::notify(ChannelKind::WhatsApp, "opportunity_alert", "item.phone"),
        ]),
        WorkflowStep::wait("operator_accept", Duration::from_secs(7200)),
    ]);

// Run it with your executor
let result = run_workflow(&my_executor, &wf, &mut ctx).await?;

Re-exports§

pub use channel::ChannelError;
pub use channel::ChannelKind;
pub use channel::NotifyChannel;
pub use context::WorkflowBranchCursorSelection;
pub use context::WorkflowContext;
pub use context::WorkflowCursor;
pub use context::WorkflowCursorFrame;
pub use context::WorkflowPendingWait;
pub use engine::LegacyQueryPayloadIssue;
pub use engine::WorkflowError;
pub use engine::WorkflowExecutor;
pub use engine::collect_legacy_query_payload_issues;
pub use engine::resume_workflow;
pub use engine::resume_workflow_with_event;
pub use engine::resume_workflow_with_event_and_options;
pub use engine::resume_workflow_with_options;
pub use engine::run_workflow;
pub use engine::run_workflow_with_options;
pub use engine::timeout_due_workflows;
pub use engine::timeout_workflow;
pub use engine::timeout_workflow_with_options;
pub use payment::ChargeRequest;
pub use payment::ChargeResponse;
pub use payment::ChargeStatus;
pub use payment::Currency;
pub use payment::OrderOrigin;
pub use payment::PaymentDisplay;
pub use payment::PaymentError;
pub use payment::PaymentEvent;
pub use payment::PaymentKind;
pub use payment::PaymentProvider;
pub use registry::StateTransition;
pub use registry::WorkflowDefinition;
pub use runtime::WorkflowLease;
pub use runtime::WorkflowLeaseOptions;
pub use runtime::WorkflowOperation;
pub use runtime::WorkflowOperationKind;
pub use runtime::WorkflowOperationStatus;
pub use runtime::WorkflowRunOptions;
pub use runtime::WorkflowSideEffect;
pub use runtime::WorkflowSideEffectKind;
pub use runtime::WorkflowSideEffectStatus;
pub use runtime::WorkflowTimeoutOutcome;
pub use state::State;
pub use step::WorkflowBranchCondition;
pub use step::WorkflowStep;

Modules§

channel
Notification channels — trait for sending messages via WhatsApp, Email, SMS, etc.
context
Workflow execution context — carries data between steps.
engine
Workflow engine — the executor trait and step runner.
payment
Payment provider trait — the abstraction over Xendit, Midtrans, DOKU, etc.
registry
Workflow registry — stores workflow definitions and state transitions.
runtime
Runtime safety contracts for workflow execution.
state
State trait — the contract domain states must implement.
step
Workflow steps — the composable building blocks of a workflow.