pub struct Cluster { /* private fields */ }Expand description
A server running across several threads, as Server::run
returns it.
Dropping this leaves the workers running; call Cluster::close to wind
them down.
Implementations§
Source§impl Cluster
impl Cluster
Sourcepub fn cores() -> usize
pub fn cores() -> usize
How many threads the machine can run at once, or 1 if that cannot be found.
Useful as the worker count for Server::run.
Sourcepub fn new(
shutdown: Sender<Option<f64>>,
threads: Vec<JoinHandle<()>>,
addresses: Vec<SocketAddr>,
) -> Self
pub fn new( shutdown: Sender<Option<f64>>, threads: Vec<JoinHandle<()>>, addresses: Vec<SocketAddr>, ) -> Self
A cluster over already-started workers.
Sourcepub fn address(&self) -> Option<SocketAddr>
pub fn address(&self) -> Option<SocketAddr>
The first bound address, if any port has one.
Sourcepub fn addresses(&self) -> &[SocketAddr]
pub fn addresses(&self) -> &[SocketAddr]
Every bound address.
Sourcepub fn close(self, timeout: Option<f64>)
pub fn close(self, timeout: Option<f64>)
Stops every worker and waits for the threads to finish.
timeout is passed to each worker’s ServerHandle::close, bounding
how long it waits for its connections. This blocks, so do not call it
from inside an async context.
Auto Trait Implementations§
impl !RefUnwindSafe for Cluster
impl !UnwindSafe for Cluster
impl Freeze for Cluster
impl Send for Cluster
impl Sync for Cluster
impl Unpin for Cluster
impl UnsafeUnpin for Cluster
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more