Expand description
Shared upstream load balancer.
A Balancer owns a pool of backend Targets and picks one per
request/connection according to a Strategy (round-robin,
least-connections, or client-IP hash). It is deliberately transport-neutral:
the HTTP upstream node and the L4 (TCP/UDP) stream proxy both select
targets through it, so the load-balancing logic lives in exactly one place.
least_connections is backed by per-target in-flight counters. Callers bump
a counter for the life of a request/connection by holding a guard:
ConnGuard (borrowed — held on the stack for a single request) or
OwnedConnGuard (owns an Arc<Balancer> — for a long-lived connection
stored outside the borrowing scope, e.g. a UDP session in a map). Both
decrement on drop.
Structs§
- Balancer
- A pool of backend targets plus the state driving target selection.
- Conn
Guard - Decrements a target’s in-flight counter when a request/connection completes.
- Owned
Conn Guard - Owned counterpart to
ConnGuardfor connections tracked outside the borrowing scope; decrements the target’s in-flight counter on drop. - Target
- A single backend address (
host:port) connections can be forwarded to.
Enums§
- Strategy
- Strategy for picking a target from the pool.