pub struct Tenants { /* private fields */ }Expand description
The registry of tenants.
Implementations§
Source§impl Tenants
impl Tenants
Sourcepub fn backup(&self, who: Actor, to: &Path) -> Result<Backup, BackupError>
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
impl Tenants
Sourcepub fn key_order(&self) -> Result<KeyOrder, TenantError>
pub fn key_order(&self) -> Result<KeyOrder, TenantError>
Counts the tenants whose data is not all under their current key.
Sourcepub fn tenants_with_packed_versions(&self) -> Result<u64, TenantError>
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].
Sourcepub fn rotation_backlog(&self) -> Result<RotationBacklog, TenantError>
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.
Sourcepub fn examine(
&self,
default: Retention,
now: OffsetDateTime,
) -> Result<RegistryExamination, TenantError>
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
impl Tenants
Sourcepub fn create_key(
&self,
who: Actor,
tenant: Option<TenantId>,
scopes: Scopes,
label: &str,
) -> Result<NewKey, TenantError>
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.
Sourcepub fn list_keys(
&self,
who: Actor,
tenant: Option<TenantId>,
) -> Result<Vec<KeyInfo>, TenantError>
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.
Sourcepub fn revoke_key(&self, who: Actor, id: KeyId) -> Result<(), TenantError>
pub fn revoke_key(&self, who: Actor, id: KeyId) -> Result<(), TenantError>
Revokes a key; revoking it again changes nothing.
Source§impl Tenants
impl Tenants
Sourcepub fn rekey_tenant(&self, who: Actor, id: TenantId) -> Result<(), TenantError>
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
impl Tenants
Sourcepub fn open(
dir: &Path,
master: Key,
fs: Arc<dyn Fs>,
clock: Arc<dyn Clock>,
) -> Result<Tenants, RegistryError>
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.
Sourcepub fn open_beside(
dir: &Path,
master: Key,
fs: Arc<dyn Fs>,
clock: Arc<dyn Clock>,
) -> Result<Tenants, RegistryError>
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.
Sourcepub fn create(
&self,
who: Actor,
name: &str,
retention: Option<Retention>,
) -> Result<TenantId, TenantError>
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.
Sourcepub fn list(&self, who: Actor) -> Result<Vec<TenantInfo>, TenantError>
pub fn list(&self, who: Actor) -> Result<Vec<TenantInfo>, TenantError>
Every tenant, by name.
Sourcepub fn set_retention(
&self,
who: Actor,
id: TenantId,
retention: Option<Retention>,
) -> Result<(), TenantError>
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.
Sourcepub fn set_metadata(
&self,
who: Actor,
id: TenantId,
level: Metadata,
) -> Result<(), TenantError>
pub fn set_metadata( &self, who: Actor, id: TenantId, level: Metadata, ) -> Result<(), TenantError>
Sets which clear columns the tenant’s Parquet files carry.
Sourcepub fn metadata(&self, id: TenantId) -> Result<Metadata, TenantError>
pub fn metadata(&self, id: TenantId) -> Result<Metadata, TenantError>
The tenant’s metadata level.
Sourcepub fn remove(
&self,
who: Actor,
id: TenantId,
removal: Removal,
) -> Result<(), TenantError>
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.
Sourcepub fn store(&self, id: TenantId) -> Result<Arc<Store>, TenantError>
pub fn store(&self, id: TenantId) -> Result<Arc<Store>, TenantError>
The tenant’s Store, shared by every request to it.
Sourcepub fn store_or_why(&self, id: TenantId) -> Result<Arc<Store>, OpenFailure>
pub fn store_or_why(&self, id: TenantId) -> Result<Arc<Store>, OpenFailure>
store, saying why a Store that did not open did not.
Sourcepub fn retention(&self, id: TenantId) -> Result<Option<Retention>, TenantError>
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.
Sourcepub fn ids(&self) -> Result<Vec<TenantId>, TenantError>
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.
Sourcepub fn export_admin(
&self,
since: Option<i64>,
out: &mut dyn Write,
) -> Result<(), AuditError>
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.
Sourcepub fn audit_page(
&self,
who: Actor,
query: &AuditQuery,
) -> Result<Vec<u8>, TenantError>
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.
Sourcepub fn check(&self) -> Result<(), TenantError>
pub fn check(&self) -> Result<(), TenantError>
Whether server.sqlite answers a query, for the health route.
Auto Trait Implementations§
impl !Freeze for Tenants
impl !RefUnwindSafe for Tenants
impl !UnwindSafe for Tenants
impl Forget for Tenants
impl Send for Tenants
impl Sync for Tenants
impl Unpin for Tenants
impl UnsafeUnpin for Tenants
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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