pub struct CanaryLayer { /* private fields */ }Expand description
Weighted traffic-splitting proxy middleware.
The rotation is pre-expanded so that each backend appears exactly weight
times. An atomic counter selects the next entry in the rotation on every
request, giving a deterministic, lock-free weighted round-robin distribution.
Implementations§
Source§impl CanaryLayer
impl CanaryLayer
Sourcepub fn new(backends: Vec<WeightedBackend>) -> Self
pub fn new(backends: Vec<WeightedBackend>) -> Self
Build a CanaryLayer from the given weighted backends.
Backends with weight == 0 are ignored.
Sourcepub fn path_prefix(self, prefix: impl Into<String>) -> Self
pub fn path_prefix(self, prefix: impl Into<String>) -> Self
Only proxy requests whose URI starts with prefix; pass others through.
Sourcepub fn connect_timeout_ms(self, ms: u64) -> Self
pub fn connect_timeout_ms(self, ms: u64) -> Self
Override the TCP connect timeout (default: 5 000 ms).
Sourcepub fn read_timeout_ms(self, ms: u64) -> Self
pub fn read_timeout_ms(self, ms: u64) -> Self
Override the response read timeout (default: 30 000 ms).
Trait Implementations§
Source§impl Middleware for CanaryLayer
impl Middleware for CanaryLayer
fn handle( &self, request: &Request, connection: &ConnectionInfo, next: &dyn Application, ) -> Result<Response, String>
Auto Trait Implementations§
impl !Freeze for CanaryLayer
impl RefUnwindSafe for CanaryLayer
impl Send for CanaryLayer
impl Sync for CanaryLayer
impl Unpin for CanaryLayer
impl UnsafeUnpin for CanaryLayer
impl UnwindSafe for CanaryLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more