TenantCtx

Struct TenantCtx 

Source
pub struct TenantCtx {
Show 18 fields pub env: EnvId, pub tenant: TenantId, pub tenant_id: TenantId, pub team: Option<TeamId>, pub team_id: Option<TeamId>, pub user: Option<UserId>, pub user_id: Option<UserId>, pub session_id: Option<String>, pub flow_id: Option<String>, pub node_id: Option<String>, pub provider_id: Option<String>, pub trace_id: Option<String>, pub correlation_id: Option<String>, pub attributes: BTreeMap<String, String>, pub deadline: Option<InvocationDeadline>, pub attempt: u32, pub idempotency_key: Option<String>, pub impersonation: Option<Impersonation>,
}
Expand description

Context that accompanies every invocation across Greentic runtimes.

Fields§

§env: EnvId

Environment scope (for example dev, staging, or prod).

§tenant: TenantId

Tenant identifier for the current execution.

§tenant_id: TenantId

Stable tenant identifier reference used across systems.

§team: Option<TeamId>

Optional team identifier scoped to the tenant.

§team_id: Option<TeamId>

Optional team identifier accessible via the shared schema.

§user: Option<UserId>

Optional user identifier scoped to the tenant.

§user_id: Option<UserId>

Optional user identifier aligned with the shared schema.

§session_id: Option<String>

Optional session identifier propagated by the runtime.

§flow_id: Option<String>

Optional flow identifier for the current execution.

§node_id: Option<String>

Optional node identifier within the flow.

§provider_id: Option<String>

Optional provider identifier describing the runtime surface.

§trace_id: Option<String>

Distributed tracing identifier when available.

§correlation_id: Option<String>

Correlation identifier for linking related events.

§attributes: BTreeMap<String, String>

Free-form attributes for routing and tracing.

§deadline: Option<InvocationDeadline>

Deadline when the invocation should finish.

§attempt: u32

Attempt counter for retried invocations (starting at zero).

§idempotency_key: Option<String>

Stable idempotency key propagated across retries.

§impersonation: Option<Impersonation>

Optional impersonation context describing the acting identity.

Implementations§

Source§

impl TenantCtx

Source

pub fn identity(&self) -> TenantIdentity

Returns the tenant identity derived from this context.

Source

pub fn tenant_context(&self) -> TenantContext

Returns the lightweight tenant context shared with tooling.

Source

pub fn impersonated_by(&self) -> Option<&Impersonation>

Returns the impersonation context, when present.

Source

pub fn with_identity(self, identity: TenantIdentity) -> Self

Updates the identity fields to match the provided value.

Source§

impl TenantCtx

Source

pub fn new(env: EnvId, tenant: TenantId) -> Self

Creates a new tenant context with the provided environment and tenant identifiers.

Source

pub fn with_team(self, team: Option<TeamId>) -> Self

Updates the team information ensuring legacy and shared fields stay aligned.

Source

pub fn with_user(self, user: Option<UserId>) -> Self

Updates the user information ensuring legacy and shared fields stay aligned.

Source

pub fn with_session(self, session: impl Into<String>) -> Self

Updates the session identifier.

Source

pub fn with_flow(self, flow: impl Into<String>) -> Self

Updates the flow identifier.

Source

pub fn with_node(self, node: impl Into<String>) -> Self

Updates the node identifier.

Source

pub fn with_provider(self, provider: impl Into<String>) -> Self

Updates the provider identifier.

Source

pub fn with_attributes(self, attributes: BTreeMap<String, String>) -> Self

Attaches or replaces the attributes map.

Source

pub fn with_impersonation(self, impersonation: Option<Impersonation>) -> Self

Sets the impersonation context.

Source

pub fn with_attempt(self, attempt: u32) -> Self

Returns a copy of the context with the provided attempt value.

Source

pub fn with_deadline(self, deadline: Option<InvocationDeadline>) -> Self

Updates the deadline metadata for subsequent invocations.

Source

pub fn session_id(&self) -> Option<&str>

Returns the session identifier, when present.

Source

pub fn flow_id(&self) -> Option<&str>

Returns the flow identifier, when present.

Source

pub fn node_id(&self) -> Option<&str>

Returns the node identifier, when present.

Source

pub fn provider_id(&self) -> Option<&str>

Returns the provider identifier, when present.

Trait Implementations§

Source§

impl Clone for TenantCtx

Source§

fn clone(&self) -> TenantCtx

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TenantCtx

Source§

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

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

impl<'de> Deserialize<'de> for TenantCtx

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&TenantCtx> for TenantContext

Source§

fn from(ctx: &TenantCtx) -> Self

Converts to this type from the input type.
Source§

impl From<&TenantCtx> for TenantIdentity

Source§

fn from(ctx: &TenantCtx) -> Self

Converts to this type from the input type.
Source§

impl Hash for TenantCtx

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TenantCtx

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for TenantCtx

Source§

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

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

impl Eq for TenantCtx

Source§

impl StructuralPartialEq for TenantCtx

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

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

§

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

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,