pub struct ServiceHost { /* private fields */ }Expand description
Runs Services until told to stop.
The rules it schedules by: Every counts from launch
to launch, a service never overlaps itself, a failure doubles the wait
per failure in a row (up to 2^5, reset by a success),
DailyUtc runs once a day at its UTC time (a
failed run waits for the next day), due work starts on the next tick or
wake-up, and every launch ends with exactly one ServiceEvent::Ended.
Implementations§
Source§impl ServiceHost
impl ServiceHost
Sourcepub fn new(tick: Duration) -> ServiceHost
pub fn new(tick: Duration) -> ServiceHost
A host that looks for due work every tick.
Sourcepub fn max_concurrent(self, limit: usize) -> ServiceHost
pub fn max_concurrent(self, limit: usize) -> ServiceHost
At most limit Schedule::Every runs at once.
Sourcepub fn grace(self, grace: Duration) -> ServiceHost
pub fn grace(self, grace: Duration) -> ServiceHost
How long a stopping host waits for runs to end before aborting them.
pub fn gate(self, gate: Arc<dyn ServiceGate>) -> ServiceHost
pub fn observer(self, observer: Arc<dyn ServiceObserver>) -> ServiceHost
pub fn service(self, service: Arc<dyn Service>) -> ServiceHost
pub fn waker(&self) -> ServiceWaker
Sourcepub async fn run(self, shutdown: CancellationToken)
pub async fn run(self, shutdown: CancellationToken)
Run until shutdown is cancelled, then stop launching, drain for the
grace period, abort what is left and call each service’s stop.
Auto Trait Implementations§
impl !RefUnwindSafe for ServiceHost
impl !UnwindSafe for ServiceHost
impl Forget for ServiceHost
impl Freeze for ServiceHostwhere
*const u8 is !null: Freeze,
PhantomData<Slot>: Freeze,
*const ArcInner<Semaphore> is !null: Freeze,
PhantomData<ArcInner<Semaphore>>: Freeze,
*const ArcInner<dyn ServiceGate> is !null: Freeze,
PhantomData<ArcInner<dyn ServiceGate>>: Freeze,
*const ArcInner<dyn ServiceObserver> is !null: Freeze,
PhantomData<ArcInner<dyn ServiceObserver>>: Freeze,
*const ArcInner<Notify> is !null: Freeze,
PhantomData<ArcInner<Notify>>: Freeze,
impl Move for ServiceHost
impl Send for ServiceHost
impl Sync for ServiceHost
impl Unpin for ServiceHost
impl UnsafeUnpin for ServiceHostwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Slot>: UnsafeUnpin,
*const ArcInner<Semaphore> is !null: UnsafeUnpin,
PhantomData<ArcInner<Semaphore>>: UnsafeUnpin,
*const ArcInner<dyn ServiceGate> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ServiceGate>>: UnsafeUnpin,
*const ArcInner<dyn ServiceObserver> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ServiceObserver>>: UnsafeUnpin,
*const ArcInner<Notify> is !null: UnsafeUnpin,
PhantomData<ArcInner<Notify>>: UnsafeUnpin,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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