Skip to main content

TenancyRouter

Struct TenancyRouter 

Source
pub struct TenancyRouter<T> { /* private fields */ }
Expand description

Turns a TenancySpi implementation into a RoutingSpi.

Implementations§

Source§

impl<T: TenancySpi> TenancyRouter<T>

Source

pub fn new(spi: T) -> Self

Wraps a tenancy implementation.

Source

pub fn spi(&self) -> &T

The wrapped tenancy implementation.

Source

pub async fn admit_write(&self, partition: &PartitionId, epoch: Epoch) -> bool

The migration write gate for a resolved decision (docs/06 §2): whether a write that resolved at epoch for partition may still commit. The engine calls this at dispatch; false is surfaced as a retryable stale-epoch error. Delegates to the TenancySpi.

Source

pub async fn resolve(&self, ctx: &RequestCtx<'_>) -> Result<Resolved, SpiError>

Resolves the full routing plan for ctx (the single-document path).

§Errors

Returns SpiError if the endpoint is not tenancy-aware, the partition cannot be resolved, no placement exists, or the configured transforms are invalid (e.g. a shared-index id rule that omits the partition).

Source

pub fn resolve_partition( &self, ctx: &RequestCtx<'_>, body: BodyDoc<'_>, ) -> Result<PartitionId, SpiError>

Resolves just the partition id for a request and document, without a placement lookup. The per-document entry point for bulk demux (docs/04 §3), where each operation carries its own source as a BodyDoc.

§Errors

Returns SpiError::PartitionUnresolved if no configured source yields the partition.

Source

pub async fn resolve_placement( &self, ctx: &RequestCtx<'_>, partition: PartitionId, logical_index: &str, ) -> Result<Resolved, SpiError>

Resolves a known partition to its placement and the routing plan for a given logical index. Separated from Self::resolve_partition so a bulk request can resolve the partition per document but cache the placement per partition.

§Errors

Returns SpiError if no placement exists or the configured transforms are invalid (e.g. a shared-index id rule that omits the partition).

Trait Implementations§

Source§

impl<T: Debug> Debug for TenancyRouter<T>

Source§

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

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

impl<T: TenancySpi> Router for TenancyRouter<T>

Source§

async fn resolve(&self, ctx: &RequestCtx<'_>) -> Result<Resolved, SpiError>

Resolves the full routing plan for a single-document request. Read more
Source§

fn resolve_partition( &self, ctx: &RequestCtx<'_>, body: BodyDoc<'_>, ) -> Result<PartitionId, SpiError>

Resolves just the partition id for a request and document (the bulk demux entry point). Read more
Source§

async fn resolve_placement( &self, ctx: &RequestCtx<'_>, partition: PartitionId, logical_index: &str, ) -> Result<Resolved, SpiError>

Resolves a known partition to its placement and routing plan. Read more
Source§

async fn admit_write(&self, partition: &PartitionId, epoch: Epoch) -> bool

The migration write gate: may a write that resolved at epoch for partition still commit? false ⇒ reject as a retryable stale-epoch error.
Source§

fn cluster_endpoint(&self, cluster: &ClusterId) -> Option<String>

The base URL of a cluster by id, for the cursor-affinity and admin paths that route by cluster without a placement. Default None.
Source§

impl<T: TenancySpi> RoutingSpi for TenancyRouter<T>

Source§

async fn route(&self, ctx: &RequestCtx<'_>) -> Result<RouteDecision, SpiError>

Resolves the routing decision for an authenticated request. Read more

Auto Trait Implementations§

§

impl<T> Freeze for TenancyRouter<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for TenancyRouter<T>
where T: RefUnwindSafe,

§

impl<T> Send for TenancyRouter<T>
where T: Send,

§

impl<T> Sync for TenancyRouter<T>
where T: Sync,

§

impl<T> Unpin for TenancyRouter<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for TenancyRouter<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for TenancyRouter<T>
where T: UnwindSafe,

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

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

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.