1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! 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>(())
//! ```
pub use CircuitState;
pub use ;
pub use health_loop;
pub use ;