pub struct InvalidationConfig {
pub debounce_ms: u64,
pub max_debounce_ms: u64,
pub coalesce_by_table: bool,
pub max_buffer_size: usize,
}Expand description
Configuration for the invalidation engine.
The invalidation engine uses a debounce algorithm to batch rapid changes into single re-executions. This prevents “thundering herd” scenarios where a batch insert of 1000 rows would trigger 1000 subscription refreshes.
The algorithm works as follows:
- When a change arrives, record the subscription as pending
- Wait for
debounce_msof silence (no new changes to that subscription) - If
max_debounce_mspasses since the first change, flush anyway - If buffer exceeds
max_buffer_size, flush immediately (memory protection)
This balances latency (users want updates fast) against efficiency (batching reduces database load). Default values target 50ms debounce with 200ms max wait, meaning updates arrive within 200ms worst-case.
Fields§
§debounce_ms: u64Debounce window in milliseconds. After a change, wait this long for more changes before invalidating.
max_debounce_ms: u64Maximum debounce wait in milliseconds. Even if changes keep arriving, invalidate after this duration.
coalesce_by_table: boolWhether to coalesce changes by table. When true, multiple changes to the same table become a single invalidation.
max_buffer_size: usizeMaximum changes to buffer before forcing flush. Prevents unbounded memory growth during high-throughput periods.
Trait Implementations§
Source§impl Clone for InvalidationConfig
impl Clone for InvalidationConfig
Source§fn clone(&self) -> InvalidationConfig
fn clone(&self) -> InvalidationConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InvalidationConfig
impl Debug for InvalidationConfig
Auto Trait Implementations§
impl Freeze for InvalidationConfig
impl RefUnwindSafe for InvalidationConfig
impl Send for InvalidationConfig
impl Sync for InvalidationConfig
impl Unpin for InvalidationConfig
impl UnwindSafe for InvalidationConfig
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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