pub struct CommitPolicy { /* private fields */ }Expand description
When crate::Salamander::append should trigger an automatic
commit() on the caller’s behalf.
Thresholds are combinable — set any subset with the and_* builders;
a commit fires when any active threshold is crossed. Byte and count
thresholds are exact (checked after every append, so a crossing
commits immediately). The time threshold is best-effort: with no
background thread in Phase 1.5 (that’s a Phase 3 concern), it can only be
noticed on the next append after the interval has elapsed — an idle DB
does not self-commit.
use salamander::CommitPolicy;
// fsync every 64 KiB *or* every 200 ms, whichever comes first:
let policy = CommitPolicy::every_bytes(64 * 1024).and_millis(200);Implementations§
Source§impl CommitPolicy
impl CommitPolicy
Sourcepub const fn manual() -> Self
pub const fn manual() -> Self
No auto-commit — the caller drives durability by calling commit()
itself. This is the default (CommitPolicy::default()).
Sourcepub const fn every_bytes(bytes: u64) -> Self
pub const fn every_bytes(bytes: u64) -> Self
Commit once this many uncommitted payload bytes have accumulated.
Sourcepub const fn every_count(count: u64) -> Self
pub const fn every_count(count: u64) -> Self
Commit once this many events have been appended since the last commit.
Sourcepub const fn every_millis(millis: u64) -> Self
pub const fn every_millis(millis: u64) -> Self
Commit on the first append at least this many milliseconds after the last commit (best-effort — see the type docs).
Sourcepub const fn and_bytes(self, bytes: u64) -> Self
pub const fn and_bytes(self, bytes: u64) -> Self
Add a byte threshold to an existing policy (combinable).
Sourcepub const fn and_count(self, count: u64) -> Self
pub const fn and_count(self, count: u64) -> Self
Add a count threshold to an existing policy (combinable).
Sourcepub const fn and_millis(self, millis: u64) -> Self
pub const fn and_millis(self, millis: u64) -> Self
Add a time threshold to an existing policy (combinable).
Trait Implementations§
Source§impl Clone for CommitPolicy
impl Clone for CommitPolicy
Source§fn clone(&self) -> CommitPolicy
fn clone(&self) -> CommitPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more