pub struct RetentionPolicy {
pub terminal_max_age: Duration,
pub batch_size: u32,
pub max_batches: Option<u32>,
}Expand description
How long terminal tasks are kept, and how aggressively they are removed.
Fields§
§terminal_max_age: DurationTerminal tasks whose last update is older than this are eligible.
Measured against updated_at, which the store maintains, and evaluated
by the database rather than the caller — an application clock that runs
fast would otherwise delete work that is younger than it looks.
batch_size: u32Rows per DELETE. Default 1,000.
The point of batching is the lock, not the throughput. One statement deleting a million rows holds locks and grows a transaction for as long as it takes; a thousand statements deleting a thousand rows each let every other query through in between.
max_batches: Option<u32>Stop after this many batches, leaving the rest for the next call.
None runs until nothing is left.
Set it to bound how long one sweep can run when the first sweep after switching retention on has years of backlog to work through.
Implementations§
Source§impl RetentionPolicy
impl RetentionPolicy
Sourcepub const fn new(terminal_max_age: Duration) -> Self
pub const fn new(terminal_max_age: Duration) -> Self
A policy keeping terminal tasks for terminal_max_age, with default
batching.
Sourcepub const fn with_batch_size(self, batch_size: u32) -> Self
pub const fn with_batch_size(self, batch_size: u32) -> Self
Sets the rows-per-DELETE batch size. Zero is treated as one.
Sourcepub const fn with_max_batches(self, max_batches: u32) -> Self
pub const fn with_max_batches(self, max_batches: u32) -> Self
Bounds how many batches a single sweep runs.
Trait Implementations§
Source§impl Clone for RetentionPolicy
impl Clone for RetentionPolicy
Source§fn clone(&self) -> RetentionPolicy
fn clone(&self) -> RetentionPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RetentionPolicy
impl RefUnwindSafe for RetentionPolicy
impl Send for RetentionPolicy
impl Sync for RetentionPolicy
impl Unpin for RetentionPolicy
impl UnsafeUnpin for RetentionPolicy
impl UnwindSafe for RetentionPolicy
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