Skip to main content

Store

Struct Store 

Source
pub struct Store { /* private fields */ }
Expand description

One tenant’s vCons.

Implementations§

Source§

impl Store

Source

pub fn backup_to(&self, dir: &Path) -> Result<Copied, BackupError>

Copies this tenant’s catalog and object files into dir, made if new. Anything already in dir from an earlier try is replaced or removed.

Each try copies the catalog first, in one step inside one read transaction, then the object file of each version row in that copy. An object file is written once and never changed, so a file copied at any try is still right; a row whose file is gone was purged after the copy, and the next try copies the catalog again. Files the final copy has no row for are removed. Every file and directory written is synced, so the backup is whole once this returns.

Source§

impl Store

Source

pub fn examine( &self, retention: Retention, key_since: OffsetDateTime, now: OffsetDateTime, ) -> Result<Examination, ExamineError>

Examines the Store under retention at now, counting purges made since key_since.

Source

pub fn purges_since( &self, since: OffsetDateTime, ) -> Result<(u64, Option<OffsetDateTime>), StoreError>

How many purges were recorded since since, and when the oldest of them was made: work only the tenant key’s next rotation finishes.

Source§

impl Store

Source

pub fn tenant(&self) -> TenantId

The tenant this Store holds.

Source

pub fn kept_versions( &self, since: Option<i64>, until: Option<i64>, ) -> Result<Vec<KeptVersion>, StoreError>

Every kept version, live or hidden, stored at or after since and before until (nanoseconds since the epoch), by store time and then version id, all from one snapshot of the catalog.

Source

pub fn sealed_of( &self, kept: &KeptVersion, ) -> Result<Option<Vec<u8>>, StoreError>

The sealed blob of a version kept_versions listed, from its object or its pack file, byte for byte. None when the version has been purged since: its row is gone and its blob with it. A blob missing while its row is still there is damage.

Source

pub fn open_sealed( &self, kept: &KeptVersion, sealed: &[u8], ) -> Result<Vec<u8>, StoreError>

The body sealed, the object of kept, holds: what get returns.

Source§

impl Store

Source

pub fn legal_get( &self, who: &Caller, uuid: Uuid, version: Option<VersionId>, ) -> Result<Legal, StoreError>

Reads version of uuid, or with None its current version, or its latest kept one when the uuid is deleted. A version purged, never stored or of another uuid is NotFound; a purged uuid is Gone. The whole read, object included, is one immediate transaction, so a purge cannot remove what is being read. Each answer is recorded.

Source

pub fn legal_versions( &self, who: &Caller, uuid: Uuid, ) -> Result<Vec<VersionInfo>, StoreError>

Every kept version of uuid, oldest first, with its times. A purged uuid is Gone and one never stored NotFound. Each answer is recorded.

Source

pub fn restore(&self, who: &Caller, uuid: Uuid) -> Result<VersionId, StoreError>

Makes the latest kept version of a deleted uuid current again: its hidden time and the uuid’s deleted time are cleared, so no sweep purges it. Older hidden versions stay hidden. A live uuid is NotDeleted, a purged one Gone, one never stored NotFound. Recorded.

Source

pub fn set_hold( &self, who: &Caller, uuid: Uuid, on: bool, ) -> Result<(), StoreError>

Turns the legal hold on uuid on or off. A held uuid is never purged; a delete still hides it. A purged uuid is Gone, one never stored NotFound. Recorded.

Source§

impl Store

Source

pub fn list( &self, who: &Caller, query: &ListQuery, ) -> Result<Listing, StoreError>

A page of the tenant’s live vCons, newest first by when each uuid was first stored, then by uuid. The page and its audit record are one transaction.

Source§

impl Store

Source

pub fn purge_due(&self, retention: Retention) -> Result<PurgeReport, StoreError>

Erases every version due under retention. Each goes in a transaction of its own that checks the rule again, so a restore or a hold that commits first keeps it. The transaction deletes the version’s row, and with it the only copy of its wrapped data key, and records the purge; a deleted uuid left with no version gives up its row for a tombstone. The object file is removed after the commit. Last, the WAL is checkpointed with truncation, tried again while readers finish, so no page that held a purged key is left in it.

Source§

impl Store

Source

pub fn rewrap(&self, new: &Key, limit: usize) -> Result<usize, StoreError>

Rewraps up to limit of the data keys still wrapped under this Store’s tenant key so they are wrapped under new, in one transaction, and returns how many it rewrapped; 0 means none is left. Each rewrap is counted against new, and refused at its wrap limit.

Source

pub fn rows_under_other_keys(&self) -> Result<u64, StoreError>

How many version rows name a key other than this Store’s tenant key: a rotation stopped part way leaves some.

Source§

impl Store

Source

pub fn open( dir: &Path, tenant: TenantId, tenant_key: Key, fs: Arc<dyn Fs>, clock: Arc<dyn Clock>, ) -> Result<Store, OpenError>

Opens the tenant’s local catalog under its catalog key, making it if new, then runs start-up recovery.

Source

pub fn open_beside( dir: &Path, tenant: TenantId, tenant_key: Key, fs: Arc<dyn Fs>, clock: Arc<dyn Clock>, ) -> Result<Store, OpenError>

Opens the store as a command running beside a server does: without start-up recovery, which would take the server’s writes in progress for a crash’s leftovers.

Source

pub fn create( &self, who: &Caller, found: &Inspection, body: &[u8], ) -> Result<Created, StoreError>

Stores a new vCon. The uuid’s state is checked before anything is sealed, the body is written in the order below, and the commit checks the state again, so of two racing writers one wins and the other’s object is removed.

Source

pub fn get(&self, who: &Caller, uuid: Uuid) -> Result<Stored, StoreError>

Reads the current version of uuid. The body is decrypted whole, then one transaction checks that the version is still current and commits the audit record; only then is the body returned. If the version changed meanwhile, the read starts again.

Source

pub fn replace( &self, who: &Caller, if_match: VersionId, found: &Inspection, body: &[u8], ) -> Result<VersionId, StoreError>

Replaces the current version of found.uuid, if it is if_match and neither signed nor encrypted. The caller has checked that the body’s uuid is the one asked for. The old version is hidden, and kept for legal reads until it is purged. As in create, the state is checked before sealing and again at the commit, so of two racing replaces one wins and the other’s object is removed.

Source

pub fn delete( &self, who: &Caller, uuid: Uuid, retention: Retention, ) -> Result<(), StoreError>

Deletes uuid: one transaction marks it deleted, empties its current version and hides every kept version, with the audit record. Its versions stay for legal reads until they are purged; any already as old as retention is purged at once, so a zero period erases the vCon inside the request. Deleting a deleted or purged uuid succeeds again. A legal hold does not stop a delete, only a purge.

Source

pub fn check(&self) -> Result<Vec<VersionId>, StoreError>

Every version whose object is missing, or, for a packed version, whose pack file is missing or not the length its row says. Such a version answers 500 when read; it is reported, never dropped.

Source

pub fn packed_versions(&self) -> Result<u64, StoreError>

How many versions are packed into pack files: once there are any, the storage must keep Parquet storage on, since nothing turns them back into objects.

Source

pub fn counts(&self) -> Result<Counts, StoreError>

How many versions the Store keeps and how many uuids are held.

Source

pub fn export( &self, since: Option<i64>, out: &mut dyn Write, ) -> Result<(), AuditError>

Writes the tenant’s log after since as JSON lines, oldest first. Not recorded: reading the log changes nothing.

Source

pub fn audit_page( &self, who: &Caller, query: &AuditQuery, ) -> Result<Vec<u8>, StoreError>

A page of the tenant’s log as JSON lines, the lines export writes for the same records. The read is recorded as audit_read in the same log and transaction, after the page is read, so a page never holds its own record.

Source

pub fn log(&self, entry: &Entry) -> Result<(), StoreError>

Records, in a transaction of its own, an action on the tenant taken elsewhere, such as a change to its retention period.

Source

pub fn count(&self, entry: &Entry) -> Result<(), StoreError>

Counts, in a transaction of its own, an event the tenant’s log keeps one record per minute for, such as a failed check of one of its keys.

Auto Trait Implementations§

§

impl !Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl !UnwindSafe for Store

§

impl Forget for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more