Skip to main content

loadwise_core/
lib.rs

1//! Core traits, built-in strategies, and in-memory stores for the loadwise
2//! load balancing engine.
3//!
4//! This crate is protocol-agnostic — it answers one question:
5//! *"given these nodes and their current state, which one should handle the next request?"*
6//!
7//! # Quick start
8//!
9//! ```
10//! # extern crate loadwise_core as loadwise;
11//! use loadwise::{Strategy, strategy::RoundRobin, SelectionContext};
12//!
13//! let strategy = RoundRobin::new();
14//! let backends = ["10.0.0.1:8080", "10.0.0.2:8080", "10.0.0.3:8080"];
15//! let ctx = SelectionContext::default();
16//!
17//! let idx = strategy.select(&backends, &ctx).unwrap();
18//! println!("route to {}", backends[idx]);
19//! ```
20
21pub mod filter;
22pub mod health;
23pub mod metrics;
24pub mod node;
25pub mod quota;
26pub mod state;
27pub mod strategy;
28pub(crate) mod window;
29
30pub use filter::{Filter, HealthAware, HealthFilter, QuotaFilter};
31pub use health::{ConsecutiveFailurePolicy, HealthPolicy, HealthStatus, HealthTracker, NodeHealth, Outcome};
32pub use metrics::{MetricsCollector, NoopCollector};
33pub use node::{LoadMetric, Node, RateMetric, Weighted};
34pub use quota::{QuotaConfig, QuotaDimension, QuotaTracker};
35pub use state::{InMemoryStore, StateStore};
36pub use strategy::{SelectionContext, Strategy};