Ranvier Runtime (ranvier-runtime)
The Engine: Async execution and state management for Ranvier circuits.
Purpose
ranvier-runtime provides the execution engine for Ranvier's typed decision pipelines:
- Axon Execution: Composable pipeline builder with
.then()chaining - Resilience:
then_with_retry()andthen_with_timeout()for production-grade fault tolerance - Persistence: Durable checkpointing via
PersistenceStoretrait (InMemory, PostgreSQL, Redis) - Compensation: Automatic rollback hooks on irrecoverable faults
Axon Builder
use ;
use *;
use Duration;
let pipeline = new
.then
.then_with_retry
.then_with_timeout;
Resilience Methods
| Method | Purpose |
|---|---|
then_with_retry(transition, policy) |
Retry on Fault with configurable backoff |
then_with_timeout(transition, duration, error_fn) |
Cancel execution if duration exceeded |
RetryPolicy options:
RetryPolicy::fixed(max_attempts, delay)— constant delay between retriesRetryPolicy::exponential(max, base, multiplier, cap)— exponential backoffRetryPolicy::exponential_default(max, initial_ms)— exponential with 2x multiplier
Persistence Stores
| Adapter | Feature flag | Best for |
|---|---|---|
InMemoryPersistenceStore |
none (default) | tests, local dev |
PostgresPersistenceStore |
persistence-postgres |
durable production storage |
RedisPersistenceStore |
persistence-redis |
ephemeral/fast checkpoints |
# Enable PostgreSQL persistence
[]
= { = "0.32", = ["persistence-postgres"] }
use ;
let pool = new
.max_connections
.connect
.await?;
let store = new;
store.ensure_schema.await?;
let handle = from_store;
let mut bus = ranvier_bus!;
Examples
hello-world— HTTP ingress baselineorder-processing-demo— Multi-step order processing pipelinestate-persistence-demo— Persistence, recovery, and compensationresilience-patterns-demo— Retry and timeout patternsservice-call-demo— HTTP client as Transition
MSRV
- Rust
1.93.0or newer (Edition 2024).