Skip to main content

Tenants

Struct Tenants 

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

The registry of tenants.

Implementations§

Source§

impl Tenants

Source

pub fn backup(&self, who: Actor, to: &Path) -> Result<Backup, BackupError>

Copies the data directory into to, which must not exist, and records the run in the admin log with its outcome.

Each try copies server.sqlite in one step inside one read transaction, then each tenant that copy lists, as Store::backup_to copies one. A tenant the copy lists that is gone, or whose versions kept being purged, was removed meanwhile, and the next try copies server.sqlite again. Tenant directories the final copy does not list are removed. Tenants are copied one after another, each as it was at its own copy.

Source§

impl Tenants

Source

pub fn key_order(&self) -> Result<KeyOrder, TenantError>

Counts the tenants whose data is not all under their current key.

Source

pub fn tenants_with_packed_versions(&self) -> Result<u64, TenantError>

How many tenants have a version packed into a pack file: with any, serve needs [storage.parquet].

Source

pub fn rotation_backlog(&self) -> Result<RotationBacklog, TenantError>

The rotation backlog: purges per tenant since its key’s rotation, and removals since the master key’s.

Source

pub fn examine( &self, default: Retention, now: OffsetDateTime, ) -> Result<RegistryExamination, TenantError>

Examines every tenant at now, under its own retention period or default.

Source§

impl Tenants

Source

pub fn create_key( &self, who: Actor, tenant: Option<TenantId>, scopes: Scopes, label: &str, ) -> Result<NewKey, TenantError>

Makes a key. A tenant key holds any of write, read, delete, legal and audit; a key with no tenant is an operator key, holds only admin, and only the command line may make one.

Source

pub fn list_keys( &self, who: Actor, tenant: Option<TenantId>, ) -> Result<Vec<KeyInfo>, TenantError>

The keys of one tenant, or with None every key, oldest first.

Source

pub fn revoke_key(&self, who: Actor, id: KeyId) -> Result<(), TenantError>

Revokes a key; revoking it again changes nothing.

Source§

impl Tenants

Source

pub fn rekey_tenant(&self, who: Actor, id: TenantId) -> Result<(), TenantError>

Rotates the tenant’s key. Only the command line does this, with the server stopped.

Source§

impl Tenants

Source

pub fn open( dir: &Path, master: Key, fs: Arc<dyn Fs>, clock: Arc<dyn Clock>, ) -> Result<Tenants, RegistryError>

Opens <dir>/server.sqlite under the master key’s catalog key, making it if new, and removes any tenant directory a crash left without its row.

Source

pub fn open_beside( dir: &Path, master: Key, fs: Arc<dyn Fs>, clock: Arc<dyn Clock>, ) -> Result<Tenants, RegistryError>

Opens the registry as a command running beside a server does: without start-up recovery, here or in any Store it opens, which would take the server’s creates and writes in progress for a crash’s leftovers.

Source

pub fn create( &self, who: Actor, name: &str, retention: Option<Retention>, ) -> Result<TenantId, TenantError>

Makes a tenant: a new tenant key wrapped under the master key, the tenant’s directory and catalog, and then its row. A create that fails after making its directory removes it if it can; any directory left without a row, by a crash or a failed removal, goes at the next start.

Source

pub fn list(&self, who: Actor) -> Result<Vec<TenantInfo>, TenantError>

Every tenant, by name.

Source

pub fn set_retention( &self, who: Actor, id: TenantId, retention: Option<Retention>, ) -> Result<(), TenantError>

Sets the tenant’s retention period, or with None returns it to the server default.

Source

pub fn set_metadata( &self, who: Actor, id: TenantId, level: Metadata, ) -> Result<(), TenantError>

Sets which clear columns the tenant’s Parquet files carry.

Source

pub fn metadata(&self, id: TenantId) -> Result<Metadata, TenantError>

The tenant’s metadata level.

Source

pub fn remove( &self, who: Actor, id: TenantId, removal: Removal, ) -> Result<(), TenantError>

Removes the tenant: its row and wrapped key, then its directory.

The tenant is drained before it is looked at, so a write that lands meanwhile counts: an Empty removal is then refused rather than losing it. A refused or failed removal leaves the tenant served again.

Source

pub fn store(&self, id: TenantId) -> Result<Arc<Store>, TenantError>

The tenant’s Store, shared by every request to it.

Source

pub fn store_or_why(&self, id: TenantId) -> Result<Arc<Store>, OpenFailure>

store, saying why a Store that did not open did not.

Source

pub fn retention(&self, id: TenantId) -> Result<Option<Retention>, TenantError>

A tenant’s own retention period, None when it uses the server default, read afresh so a change counts from the next call. It is read for the server’s own use, such as a delete’s purge, so nothing is recorded.

Source

pub fn ids(&self) -> Result<Vec<TenantId>, TenantError>

Every tenant’s id, read for the server’s own use, such as the purge sweep, so nothing is recorded.

Source

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

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

Source

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

A page of the admin log as JSON lines, the lines export_admin writes for the same records. The read is recorded as audit_read in the admin log, in the same transaction, after the page is read.

Source

pub fn check(&self) -> Result<(), TenantError>

Whether server.sqlite answers a query, for the health route.

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