ferryman-core 0.2.2

Lock-free circuit breaker, prefix routing table, hot-reloadable TOML config and active health checks for the ferryman reverse proxy.
Documentation
//! ferryman-core — routing table, per-upstream circuit breaker, active
//! health checker, and TOML config schema.
//!
//! The server crate wires these primitives together behind a hyper service.
//! Everything in this crate is reload-safe: `SharedTable` is an
//! `Arc<ArcSwap<RouteTable>>` so a new table can be hot-swapped in without
//! touching live connections.
//!
//! ```
//! use ferryman_core::{build_table, ConfigToml};
//!
//! let cfg: ConfigToml = toml::from_str(r#"
//!     [[routes]]
//!     prefix = "/svc-a"
//!     upstream = "http://127.0.0.1:8001"
//! "#)?;
//! let table = build_table(cfg, None)?;
//!
//! let route = table.lookup("/svc-a/users").expect("route");
//! assert!(table.lookup("/svc-ab").is_none());
//! if let Some(ticket) = route.upstream.try_acquire() {
//!     // ... forward the request, then report the outcome:
//!     route.upstream.record_success(ticket);
//! } else {
//!     // circuit open: answer 503
//! }
//! # Ok::<(), anyhow::Error>(())
//! ```

mod breaker;
pub mod config;
pub mod health;
pub mod route;

pub use breaker::CircuitState;
pub use config::{build_table, load_config, ConfigToml, RouteToml};
pub use health::health_loop;
pub use route::{Admission, Route, RouteTable, SharedTable, Upstream};