FileSnapshotSet

Struct FileSnapshotSet 

Source
pub struct FileSnapshotSet {
    pub snapshots: Vec<SnapshotInfo>,
    /* private fields */
}
Expand description

Implementation of SnapshotSet using files on disk that exactly mirror the state in memory, i.e., each entry in snapshots corresponds to a file in the folder, even if the file is empty.

Snapshot files are always of the format snapshot_<ordinal>_<shard>-of-<shard-count>_<type>.bin

Name components:

  1. <ordinal> is a monotonically increasing sequence number
  2. <type> is one of diff, full, or pending where pending should be renamed to full once the snapshot is complete and published.
  3. <shard> is the shard number (0-based) of the snapshot
  4. <shard-count> is the total number of shards in the snapshot

<ordinal> must be processed in sequence, <shard> can be processed in parallel.

Fields§

§snapshots: Vec<SnapshotInfo>

Implementations§

Source§

impl FileSnapshotSet

Source

pub fn new(folder: &Path) -> Result<Self, Error>

Source

pub fn get_latest_full_snapshot(&self) -> Option<&SnapshotInfo>

Returns the latest full snapshot that has been published and is considered complete.

Source

pub fn get_all_diff_snapshots_since( &self, last_full_ordinal: SnapshotOrdinal, ) -> Vec<&SnapshotInfo>

Returns all differential snapshots that have been created since the snapshot with the given ordinal number. This is useful to determine which differential snapshots need to be applied to the full snapshot to get the latest state.

Trait Implementations§

Source§

impl Debug for FileSnapshotSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for FileSnapshotSet

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl SnapshotSet for FileSnapshotSet

Source§

fn create_or_get_snapshot( &mut self, snapshot_type: SnapshotType, shard_count: u64, may_append_existing: bool, ) -> Result<SnapshotInfo, Error>

Registers a new snapshot path usable for the given snapshot type. This will return a new snapshot path that can be used to write the snapshot to. Read more
Source§

fn publish_completed_snapshot( &mut self, pending_snapshot_ordinal: SnapshotOrdinal, purge_obsolete_diff_snapshots: bool, purge_obsolete_pending_snapshots: bool, ) -> Result<(), Error>

Publishes a pending snapshot as a full snapshot. This will rename the snapshot file to indicate that it is a full snapshot and considered complete. purge_obsolete_diff_snapshots specifies if differential snapshots that are now obsolete should be auto-deleted. purge_obsolete_pending_snapshots specifies if pending snapshots that precede the now completed snapshot should be auto-deleted.
Source§

fn get_snapshots_to_restore(&self) -> Vec<&SnapshotInfo>

Returns all snapshots that need to be restored in order to get the latest state. This includes the latest full snapshot and all differential snapshots since then.
Source§

impl SnapshotSetAdmin for FileSnapshotSet

Source§

fn prune_backup_snapshots( &mut self, max_backups_keep: usize, ) -> Result<(), Error>

Prunes backup snapshots, keeping only the latest max_backups_keep full snapshots. This is useful to limit the number of backup snapshots that are kept around. Warning: This will delete files from the file system.
Source§

fn prune_not_completed_snapshots(&mut self) -> Result<(), Error>

Prunes snapshots that are not completed, e.g. due to a power failure or process panic. This is useful to clean up incomplete snapshots that should not be used. Warning: This will delete files from the file system.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.