Expand description
Core traits, built-in strategies, and in-memory stores for the loadwise load balancing engine.
This crate is protocol-agnostic — it answers one question: “given these nodes and their current state, which one should handle the next request?”
§Quick start
use loadwise::{Strategy, strategy::RoundRobin, SelectionContext};
let strategy = RoundRobin::new();
let backends = ["10.0.0.1:8080", "10.0.0.2:8080", "10.0.0.3:8080"];
let ctx = SelectionContext::default();
let idx = strategy.select(&backends, &ctx).unwrap();
println!("route to {}", backends[idx]);Re-exports§
pub use filter::Filter;pub use filter::HealthAware;pub use filter::HealthFilter;pub use filter::QuotaFilter;pub use health::ConsecutiveFailurePolicy;pub use health::HealthPolicy;pub use health::HealthStatus;pub use health::HealthTracker;pub use health::NodeHealth;pub use health::Outcome;pub use metrics::MetricsCollector;pub use metrics::NoopCollector;pub use node::LoadMetric;pub use node::Node;pub use node::RateMetric;pub use node::Weighted;pub use quota::QuotaConfig;pub use quota::QuotaDimension;pub use quota::QuotaTracker;pub use state::InMemoryStore;pub use state::StateStore;pub use strategy::SelectionContext;pub use strategy::Strategy;
Modules§
- filter
- Filters for narrowing the candidate set before strategy selection.
- health
- Health state machine and tracking for backend nodes.
- metrics
- Optional observability hooks — bring your own Prometheus / OpenTelemetry.
- node
- Traits for describing backend nodes and their observable properties.
- quota
- Per-node multi-dimensional quota tracking.
- state
- Pluggable state storage for per-node runtime data.
- strategy
- Load balancing strategies and the
Strategytrait.