pub struct DrainState { /* private fields */ }Expand description
Cloneable gate shared by transports, dispatchers, worker streams, and the shutdown coordinator.
Implementations§
Source§impl DrainState
impl DrainState
Sourcepub fn is_draining(&self) -> bool
pub fn is_draining(&self) -> bool
Return whether drain has begun and new workflow/activity starts must be rejected.
Sourcepub fn begin(&self) -> bool
pub fn begin(&self) -> bool
Mark the server draining. Returns true for the first caller that changed the state.
Sourcepub async fn wait_for_drain(&self)
pub async fn wait_for_drain(&self)
Resolve as soon as drain has begun — Self::is_draining in awaitable
form, over the same latch.
For the seam that must block on an external arrival (a worker
registering) and therefore cannot re-read a flag between iterations.
Waking here decides nothing on its own: the woken caller re-runs its
normal loop and meets Self::ensure_accepting, which is still the only
place a drain refusal is produced.
Sourcepub fn ensure_accepting(
&self,
namespace: &str,
activity_type: &str,
) -> Result<(), ServerError>
pub fn ensure_accepting( &self, namespace: &str, activity_type: &str, ) -> Result<(), ServerError>
Reject a new unit of work if drain has already begun.
§Errors
Returns ServerError::WorkerDispatch with a stable drain message when work is closed.
Sourcepub fn notify_activity_drained(&self)
pub fn notify_activity_drained(&self)
Wake waiters after in-flight accounting may have reached zero.
Trait Implementations§
Source§impl Clone for DrainState
impl Clone for DrainState
Source§fn clone(&self) -> DrainState
fn clone(&self) -> DrainState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DrainState
impl Debug for DrainState
Source§impl Default for DrainState
impl Default for DrainState
Source§fn default() -> DrainState
fn default() -> DrainState
Auto Trait Implementations§
impl !RefUnwindSafe for DrainState
impl !UnwindSafe for DrainState
impl Freeze for DrainState
impl Send for DrainState
impl Sync for DrainState
impl Unpin for DrainState
impl UnsafeUnpin for DrainState
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<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> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
Source§fn into_maybe_undefined(self) -> MaybeUndefined<T>
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request