pub struct Server<T> { /* private fields */ }Expand description
Controller and completion future for a running server.
Clones can pause, resume, stop, or submit items to the server. Awaiting a
Server resolves when the server has stopped. It always resolves to
Ok(()).
Implementations§
Source§impl Server<Connection>
impl Server<Connection>
Sourcepub fn builder() -> ServerBuilder
pub fn builder() -> ServerBuilder
Creates a network server builder with no application configuration.
Source§impl<T> Server<T>
impl<T> Server<T>
Sourcepub fn metrics(&self) -> ServerMetrics
pub fn metrics(&self) -> ServerMetrics
Returns a snapshot of the server metrics.
Sourcepub fn process(&self, item: T) -> Result<(), T>
pub fn process(&self, item: T) -> Result<(), T>
Submits an item to the worker pool.
The worker is chosen on the calling thread, see
LoadBalancing.
Returns the item unchanged if the server status is not
Ready or the server cannot accept it, so
items submitted right after start or while no worker is available are
rejected.
Sourcepub fn status(&self) -> ServerStatus
pub fn status(&self) -> ServerStatus
Returns the current server status.
Sourcepub fn status_changed(&self) -> impl Future<Output = ServerStatus> + use<T>
pub fn status_changed(&self) -> impl Future<Output = ServerStatus> + use<T>
Waits for the server status to change and returns the new status.
The status is compared with the status at the time of this call, so changes made before the future is polled are not missed. Changes in quick succession may be reported once, with the latest status.
Resolves immediately with Stopped if the
server has stopped.
Sourcepub fn resume(&self) -> impl Future<Output = ()> + use<T>
pub fn resume(&self) -> impl Future<Output = ()> + use<T>
Resumes processing new items.
The server becomes Ready once a worker is
available.
Sourcepub fn stop(&self, graceful: bool) -> impl Future<Output = ()> + use<T>
pub fn stop(&self, graceful: bool) -> impl Future<Output = ()> + use<T>
Stops processing new items and shuts down all workers.
If graceful is true, workers are given up to the graceful shutdown
timeout to finish active work before they are stopped. A zero timeout
makes the stop non-graceful.
The returned future resolves once the stop has completed. If the server has already stopped, it resolves immediately.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Server<T>
impl<T> !Sync for Server<T>
impl<T> !UnwindSafe for Server<T>
impl<T> Forget for Server<T>
impl<T> Freeze for Server<T>
impl<T> Send for Server<T>
impl<T> Unpin for Server<T>
impl<T> UnsafeUnpin for Server<T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Source§impl<F> OnDropFutureExt for Fwhere
F: Future,
impl<F> OnDropFutureExt for Fwhere
F: Future,
Source§fn on_drop<F>(self, on_drop: F) -> OnDropFuture<Self, F> ⓘwhere
F: FnOnce(),
fn on_drop<F>(self, on_drop: F) -> OnDropFuture<Self, F> ⓘwhere
F: FnOnce(),
on_drop is called if the future is dropped
before it completes. The callback is cancelled once the future
completes, whatever its output.