Skip to main content

itinera/
lib.rs

1//! Itinera is a workflow framework that keeps business rules separate from flow control.
2//!
3//! Its behaviour is defined by the [Itinera specification](https://github.com/itinera-dev/spec),
4//! whose vocabulary this crate uses. This release implements tier 1 of specification 0.1.0,
5//! with the capabilities `sync`, `async` and `testing`, and passes its conformance cases
6//! `v0.1.0-rc.15`.
7//!
8//! To learn Itinera step by step, read
9//! [the Itinera book for Rust](https://itinera-dev.org/book/rust/), where every example compiles
10//! and runs. [The Itinera site](https://itinera-dev.org/) explains why Itinera exists. This
11//! documentation is the reference for each item.
12//!
13//! # The parts of a workflow
14//!
15//! - A **step** holds one business rule. It declares the data it needs, which the workflow
16//!   supplies, runs once per attempt, and reports an outcome: success, failure or skipped. Only an
17//!   attempt that succeeds commits what the step contributed. A step may have a **rescue step**,
18//!   which runs when the step fails or terminates abnormally and, once it succeeds, lets the step
19//!   run again. See [`step`].
20//! - A **service** is an object of operations a step uses to do its business, such as a payment
21//!   gateway. The step requests it by key, and a service provider of the workflow makes it, for
22//!   the journey or for each attempt. See [`service`].
23//! - A **policy** holds flow control. Its hooks, such as `on step failure` or `on workflow
24//!   success`, are called in response to a step's outcome or at the end of the journey, and may
25//!   end the journey early. A hook may use a role, an interface the workflow provides. See
26//!   [`policy`].
27//! - A **workflow** lists its steps in the order they run, with their retry budgets and policies,
28//!   its own policies, its input adapters, its service providers, its ID generator and its
29//!   reporters. It is declared once, before any journey, and a declaration that breaks a rule of
30//!   the specification is refused. See [`workflow`].
31//! - A **workflow instance** is created for each journey, with its initial data, its reporters and
32//!   any initial global metadata, and an **executor** runs it to a **result**: the journey
33//!   succeeded, failed or was aborted. See [`instance`], [`executor`] and [`journey`].
34//! - Everything that happens in a journey is an **event**, which the journey's reporters receive,
35//!   together with the journey's **global metadata**: entries of a key and a value, apart from
36//!   the data bag, starting with the journey ID. See [`event`] and [`report`].
37//!
38#![cfg_attr(feature = "macros", doc = include_str!("../docs/first-workflow.md"))]
39//!
40//! # Features
41//!
42//! - `macros`, on by default: the attributes and derives that declare steps, rescue steps,
43//!   policies, workflows, roles and journey data. They expand to builder calls and
44//!   implementations of public traits, which an application can write by hand.
45//! - `async`: the asynchronous executor, and asynchronous steps, rescue steps, hooks, service
46//!   providers, reporters and dispatchers, with `mode::async_trait` for services and roles whose
47//!   methods are asynchronous.
48//! - `testing`: test support. `report::RecordingReporter`, a reporter that keeps every event, and
49//!   the latest value of each entry of global metadata, for a test to read; fakes in place of
50//!   service providers; scripted runs; and recorders that lend a step, a hook or an input adapter
51//!   its handles outside a journey. Enable it for tests only, under `[dev-dependencies]`.
52//! - `unstable`: API the specification has not settled yet; empty for now.
53
54#![forbid(unsafe_code)]
55
56pub use itinera_core::*;