Struct tourniquet::RoundRobin [−][src]
pub struct RoundRobin<SvcSrc, Svc, E, Conn> where
Conn: Connector<SvcSrc, Svc, E>, { /* fields omitted */ }
Expand description
Round Robin manager.
This holds a list of services, a way to connect to said services, and a way to run stuff against this connected service.
Implementations
Build a new round-robin manager.
The connector is a struct that yields a connected handler to the service, from its service “source” (usually an URL). Note that the connector is lazily executed on demand when a connection is needed.
Example
use std::{io::Error, net::IpAddr};
use tokio::net::TcpStream;
use tourniquet::{Connector, RoundRobin};
struct Conn(u16);
#[async_trait]
impl Connector<IpAddr, Mutex<TcpStream>, Error> for Conn {
async fn connect(&self, src: &IpAddr) -> Result<Mutex<TcpStream>, Error> {
let Conn(ref port) = self;
TcpStream::connect((*src, *port)).await.map(Mutex::new)
}
}
let rr = RoundRobin::new(
vec!["185.30.166.38".parse().unwrap(), "66.110.9.37".parse().unwrap()],
Conn(6667),
);
Set how many times we will try the next service in case of failure.
Set how many times we will try the next service in case of failure.
Auto Trait Implementations
impl<SvcSrc, Svc, E, Conn> !RefUnwindSafe for RoundRobin<SvcSrc, Svc, E, Conn>
impl<SvcSrc, Svc, E, Conn> Send for RoundRobin<SvcSrc, Svc, E, Conn> where
Conn: Send,
E: Send,
Svc: Send + Sync,
SvcSrc: Send,
impl<SvcSrc, Svc, E, Conn> Sync for RoundRobin<SvcSrc, Svc, E, Conn> where
Conn: Sync,
E: Sync,
Svc: Send + Sync,
SvcSrc: Sync,
impl<SvcSrc, Svc, E, Conn> Unpin for RoundRobin<SvcSrc, Svc, E, Conn> where
Conn: Unpin,
E: Unpin,
SvcSrc: Unpin,
impl<SvcSrc, Svc, E, Conn> UnwindSafe for RoundRobin<SvcSrc, Svc, E, Conn> where
Conn: UnwindSafe,
E: UnwindSafe,
Svc: RefUnwindSafe,
SvcSrc: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more