pub struct CheckpointSettings {
pub check_delay: Duration,
pub minimum_changes: usize,
pub shutdown_flag: Arc<AtomicBool>,
}Expand description
Configuration settings for the provided ExtractDb::background_checkpoints.
§Examples
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::time::Duration;
use extractdb::{CheckpointSettings, ExtractDb};
let shutdown_flag = Arc::new(AtomicBool::new(false));
let mut save_settings = CheckpointSettings::new(shutdown_flag.clone());
save_settings.minimum_changes = 30;
// Checks every 5 seconds for >=30 changes.
save_settings.check_delay = Duration::from_secs(5);
// Gracefully shutdown a background thread
shutdown_flag.store(true, Ordering::Relaxed);Fields§
§check_delay: DurationInterval at which the internal_count is checked
e.g. Check the number of pushes every X seconds.
minimum_changes: usizeMinimum number of changes from the last disk write needed for a new disk write.
e.g. Write to disk after 200 push insertions.
shutdown_flag: Arc<AtomicBool>A flag to safely shut down the internal watcher thread. Use this to gracefully shutdown & save state
Implementations§
Source§impl CheckpointSettings
impl CheckpointSettings
Sourcepub fn new(shutdown_flag: Arc<AtomicBool>) -> Self
pub fn new(shutdown_flag: Arc<AtomicBool>) -> Self
Generic default settings for auto-saving in ExtractDb::background_checkpoints.
Auto Trait Implementations§
impl Freeze for CheckpointSettings
impl RefUnwindSafe for CheckpointSettings
impl Send for CheckpointSettings
impl Sync for CheckpointSettings
impl Unpin for CheckpointSettings
impl UnsafeUnpin for CheckpointSettings
impl UnwindSafe for CheckpointSettings
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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