Expand description
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
}Re-exports§
pub use config::build_table;pub use config::load_config;pub use config::ConfigToml;pub use config::RouteToml;pub use config::XffMode;pub use health::health_loop;pub use route::Admission;pub use route::Route;pub use route::RouteTable;pub use route::Upstream;
Modules§
- config
- TOML config schema + reload-time builder.
- health
- Active health checker. Probes every upstream’s health path (default
/health; upstreams withhealth_disabledare skipped entirely: no probe, no breaker effect) concurrently on a fixed interval, so one slow upstream doesn’t delay the others, and records the result through the circuit breaker. - path
- Request-path checks shared by ferryman and ferryman-edge. Detection only: the forwarded path is never rewritten.
- route
- Routing table + per-upstream circuit breaker.
Structs§
- Breaker
- Lock-free circuit breaker. Cheap to share (wrap in
Arc); an upstream’s breaker is shared between every route that points at the backend, and across hot reloads. - Breaker
Config - Circuit breaker settings. Build with
Defaultand thewith_*setters;Breaker::newvalidates them. - Trusted
Proxies - A set of CIDR ranges (
10.0.0.0/8,fd00::/8, a bare address means a single host) naming peers whose forwarding headers may be believed.
Enums§
- Circuit
State - Circuit breaker state. Mirrors the
ferryman_circuit_stategauge values. - Error
- Why a config, upstream, breaker or CIDR list was rejected.