pub struct LagRoutingConfig {Show 14 fields
pub enabled: bool,
pub poll_interval: Duration,
pub lag_calculation: LagCalculation,
pub default_max_lag: Duration,
pub fresh_threshold: Duration,
pub stale_threshold: Duration,
pub fallback_to_primary: bool,
pub fallback_threshold: Duration,
pub read_your_writes: bool,
pub ryw_retention: Duration,
pub sync_mode_limits: HashMap<SyncMode, SyncModeLagConfig>,
pub enable_smoothing: bool,
pub smoothing_window: usize,
pub min_samples: usize,
}Expand description
Main configuration for lag-aware routing
Fields§
§enabled: boolEnable lag-aware routing
poll_interval: DurationInterval between lag status polls
lag_calculation: LagCalculationMethod for calculating lag
default_max_lag: DurationDefault maximum acceptable lag for reads
fresh_threshold: DurationThreshold for considering a node “fresh”
stale_threshold: DurationThreshold for marking a node unhealthy due to lag
fallback_to_primary: boolWhether to fall back to primary when all standbys are too laggy
fallback_threshold: DurationLag threshold that triggers primary fallback
read_your_writes: boolEnable read-your-writes tracking
ryw_retention: DurationHow long to retain RYW LSN requirements
sync_mode_limits: HashMap<SyncMode, SyncModeLagConfig>Per-sync-mode lag limits
enable_smoothing: boolEnable lag trend smoothing to avoid oscillation
smoothing_window: usizeNumber of samples for trend smoothing
min_samples: usizeMinimum samples before trusting lag data
Implementations§
Source§impl LagRoutingConfig
impl LagRoutingConfig
Sourcepub fn with_poll_interval(self, interval: Duration) -> Self
pub fn with_poll_interval(self, interval: Duration) -> Self
Builder pattern: set poll interval
Sourcepub fn with_default_max_lag(self, lag: Duration) -> Self
pub fn with_default_max_lag(self, lag: Duration) -> Self
Builder pattern: set default max lag
Sourcepub fn with_fallback_threshold(self, threshold: Duration) -> Self
pub fn with_fallback_threshold(self, threshold: Duration) -> Self
Builder pattern: set fallback threshold
Sourcepub fn with_read_your_writes(self, enabled: bool) -> Self
pub fn with_read_your_writes(self, enabled: bool) -> Self
Builder pattern: enable/disable read-your-writes
Sourcepub fn with_ryw_retention(self, retention: Duration) -> Self
pub fn with_ryw_retention(self, retention: Duration) -> Self
Builder pattern: set RYW retention
Sourcepub fn with_lag_calculation(self, method: LagCalculation) -> Self
pub fn with_lag_calculation(self, method: LagCalculation) -> Self
Builder pattern: set lag calculation method
Sourcepub fn with_smoothing(self, enabled: bool, window: usize) -> Self
pub fn with_smoothing(self, enabled: bool, window: usize) -> Self
Builder pattern: enable/disable smoothing
Sourcepub fn get_sync_mode_max_lag(&self, mode: SyncMode) -> Duration
pub fn get_sync_mode_max_lag(&self, mode: SyncMode) -> Duration
Get the max lag allowed for a sync mode
Sourcepub fn get_sync_mode_weight(&self, mode: SyncMode) -> f64
pub fn get_sync_mode_weight(&self, mode: SyncMode) -> f64
Get the weight for a sync mode (for load balancing)
Trait Implementations§
Source§impl Clone for LagRoutingConfig
impl Clone for LagRoutingConfig
Source§fn clone(&self) -> LagRoutingConfig
fn clone(&self) -> LagRoutingConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LagRoutingConfig
impl Debug for LagRoutingConfig
Auto Trait Implementations§
impl Freeze for LagRoutingConfig
impl RefUnwindSafe for LagRoutingConfig
impl Send for LagRoutingConfig
impl Sync for LagRoutingConfig
impl Unpin for LagRoutingConfig
impl UnsafeUnpin for LagRoutingConfig
impl UnwindSafe for LagRoutingConfig
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
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> 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 more