pub struct TenantId(/* private fields */);Expand description
Which tenant a run, key, or decision belongs to.
Deliberately a validated newtype rather than a bare String. A tenant name
reaches storage keys and key-ring scopes, so a name containing a separator
could make two different tenants produce one scope — the failure that looks
like nothing at all until one of them erases the other’s data.
§Deserialization is a constructor, and it takes the same door
#[serde(try_from)] rather than a derived Deserialize, because a derive
would reach the private field directly and hand out exactly the names
new exists to refuse. That is not a hypothetical door: a
tenant arrives from a credential claim an Authenticator parsed, a store
row, or a journal record, and every one of those is serde rather than a
call to new. A TenantId holding acme/prod makes
keyring::scope derive one key scope for two
distinct tenants, so either tenant’s erasure destroys the other’s key and
reports success.
A stored name that no longer parses is therefore a read error, which is the honest outcome: silently accepting it is what lets the collision exist.
Implementations§
Source§impl TenantId
impl TenantId
Sourcepub const MAX_LEN: usize = 64
pub const MAX_LEN: usize = 64
The longest a tenant name may be.
Bounded because the name reaches metric labels and storage keys. An unbounded label is an unbounded cardinality problem, which is how a metrics backend falls over for a reason nobody connects to a tenant name.
Sourcepub const DEFAULT: &'static str = "default"
pub const DEFAULT: &'static str = "default"
The tenant a deployment that never named one is running as.
Single-tenant is the ordinary case and must not require ceremony. It is a real tenant rather than an absence, so the single- and multi-tenant paths are the same code — a special “no tenant” case is a second path, and the second path is the one that does not get tested.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TenantId
impl<'de> Deserialize<'de> for TenantId
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for TenantId
Source§impl Ord for TenantId
impl Ord for TenantId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for TenantId
impl PartialOrd for TenantId
impl StructuralPartialEq for TenantId
Auto Trait Implementations§
impl Freeze for TenantId
impl RefUnwindSafe for TenantId
impl Send for TenantId
impl Sync for TenantId
impl Unpin for TenantId
impl UnsafeUnpin for TenantId
impl UnwindSafe for TenantId
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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