Skip to main content

TenantStatus

Enum TenantStatus 

Source
#[non_exhaustive]
pub enum TenantStatus { Active, Provisioning, Degraded, Offboarding, Archived, }
Expand description

A tenant database’s reconciliation status.

Serializes as the registry’s own text ("active"), not the variant name, so a structured log field and a registry row cannot drift apart. round_trips_through_the_registry_text and serializes_as_the_registry_text together pin that.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Active

Reconciled and serving.

§

Provisioning

Registered, reconciliation not yet succeeded.

§

Degraded

The last reconciliation failed: requests answer 503 tenant-degraded until a boot succeeds.

§

Offboarding

Being retired: the export and key shred of docs/TENANT-ONBOARDING.md §2 are under way. It has stopped serving and will not start again.

§

Archived

Retired. The database is dropped and the keys are destroyed; nothing about this tenant can be served or recovered.

Implementations§

Source§

impl TenantStatus

Source

pub fn as_str(self) -> &'static str

The registry’s text form, lowercase and stable.

Source

pub fn is_reconciled(self) -> bool

Whether boot-time reconciliation should fly this tenant.

A match and not a negation, which is the whole point. The reconciler asked status != Degraded while there were three statuses, so it was accidentally right; adding Offboarding and Archived silently enrolled both in the fleet, which would have reconnected to a shredded tenant’s database and flipped it back to active. Written this way, the next variant added to this #[non_exhaustive] enum cannot compile until someone says which side of the line it is on.

Source

pub fn is_terminal(self) -> bool

Whether the lifecycle ends here. Only TenantStatus::Archived does: the database is dropped and the data keys are destroyed (docs/TENANT-ONBOARDING.md §2), so there is nothing left to serve and no honest way back. The registry enforces it — see Postgres::register_tenant.

Source

pub const fn admits(self) -> &'static [TenantStatus]

The statuses a tenant may be in and still become this one.

The lifecycle rule, in one place, because more than one writer moves a tenant through it: the reconciler, the offboarding runbook’s tooling and the lifecycle API of #154. A rule that lived in one adapter’s WHERE clause would be a rule the next writer did not have.

Written as “who may become me” rather than “who may I become” so the match is on the target, which is what a caller setting a status has in its hand — and so the list drops straight into the UPDATE’s WHERE as the set of previous values that may be overwritten, making the check part of the same statement rather than a read the write races.

Each status admits itself, because writing the status a tenant is already in changes nothing and a reconciler that runs twice must not fail the second time. TenantStatus::Archived is the exception: it admits nothing, itself included. The row is the record that the database was dropped and the keys destroyed, and a record of an irreversible act is not rewritten.

Source

pub fn can_become(self, next: TenantStatus) -> bool

Whether self may become next. The same rule as TenantStatus::admits, asked from the other end.

Source

pub fn parse(status: &str) -> TenantStatus

Parses the registry’s text form; anything else (a future version wrote a status this binary does not know) reads as TenantStatus::Degraded — refuse, do not guess.

Trait Implementations§

Source§

impl Clone for TenantStatus

Source§

fn clone(&self) -> TenantStatus

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TenantStatus

Source§

impl Debug for TenantStatus

Source§

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

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

impl Display for TenantStatus

Source§

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

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

impl Eq for TenantStatus

Source§

impl PartialEq for TenantStatus

Source§

fn eq(&self, other: &TenantStatus) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for TenantStatus

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TenantStatus

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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<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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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