pub struct FlowController { /* private fields */ }Expand description
Ticket-based write-admission flow controller.
Holds the soft-target policy and the live throttle state. Cheap to
share: every field is a single atomic plus the immutable quorum
config, so Self::try_admit on the write hot path is a couple of
relaxed loads.
Implementations§
Source§impl FlowController
impl FlowController
Sourcepub fn disabled() -> FlowController
pub fn disabled() -> FlowController
A disabled controller (soft target 0): never throttles.
Sourcepub fn new(soft_target_lsn: u64, quorum: QuorumConfig) -> FlowController
pub fn new(soft_target_lsn: u64, quorum: QuorumConfig) -> FlowController
Build a controller with an explicit soft target and quorum shape.
Sourcepub fn configure_soft_target(&self, soft_target_lsn: u64)
pub fn configure_soft_target(&self, soft_target_lsn: u64)
Install (or change) the soft target at runtime. 0 disables the
feature and immediately releases any active throttle.
Sourcepub fn soft_target_lsn(&self) -> u64
pub fn soft_target_lsn(&self) -> u64
Soft target in LSN records. 0 means disabled.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether flow control is enabled (soft target > 0).
Sourcepub fn is_throttled(&self) -> bool
pub fn is_throttled(&self) -> bool
Whether the throttle is currently engaged.
Sourcepub fn observed_lag_lsn(&self) -> u64
pub fn observed_lag_lsn(&self) -> u64
Most recent observed max in-quorum replica lag in LSN records.
Sourcepub fn observe(&self, replicas: &[ReplicaState], primary_lsn: u64) -> bool
pub fn observe(&self, replicas: &[ReplicaState], primary_lsn: u64) -> bool
Re-evaluate the throttle from a replica snapshot.
Computes the max lag across in-quorum replicas (async read-replicas
excluded) and engages the throttle when it exceeds the soft target,
releasing it when the quorum member recovers to/below the target.
Returns the resulting throttled state.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FlowController
impl RefUnwindSafe for FlowController
impl Send for FlowController
impl Sync for FlowController
impl Unpin for FlowController
impl UnsafeUnpin for FlowController
impl UnwindSafe for FlowController
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
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>
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>
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 moreSource§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