pub trait Router:
Send
+ Sync
+ 'static {
// Required methods
async fn resolve(&self, ctx: &RequestCtx<'_>) -> Result<Resolved, SpiError>;
fn resolve_partition(
&self,
ctx: &RequestCtx<'_>,
body: BodyDoc<'_>,
) -> Result<PartitionId, SpiError>;
async fn resolve_placement(
&self,
ctx: &RequestCtx<'_>,
partition: PartitionId,
logical_index: &str,
) -> Result<Resolved, SpiError>;
async fn admit_write(&self, partition: &PartitionId, epoch: Epoch) -> bool;
// Provided method
fn cluster_endpoint(&self, _cluster: &ClusterId) -> Option<String> { ... }
}Expand description
The partition-aware routing seam the engine pipeline drives.
RoutingSpi yields only a RouteDecision; the engine needs more, the
resolved partition (to construct _id/_routing and to demux bulk per
document), the epoch and migration phase (the write gate), and a split
resolve so a bulk request can resolve the partition per document but cache the
placement per partition. This trait captures exactly that contract, so the
pipeline is generic over any router that can provide it, not nailed to the
concrete TenancyRouter. TenancyRouter is the in-tree implementation.
Required Methods§
Sourcefn resolve_partition(
&self,
ctx: &RequestCtx<'_>,
body: BodyDoc<'_>,
) -> Result<PartitionId, SpiError>
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).
§Errors
Returns SpiError::PartitionUnresolved if no source yields a partition.
Sourceasync fn resolve_placement(
&self,
ctx: &RequestCtx<'_>,
partition: PartitionId,
logical_index: &str,
) -> Result<Resolved, SpiError>
async fn resolve_placement( &self, ctx: &RequestCtx<'_>, partition: PartitionId, logical_index: &str, ) -> Result<Resolved, SpiError>
Sourceasync fn admit_write(&self, partition: &PartitionId, epoch: Epoch) -> bool
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.
Provided Methods§
Sourcefn cluster_endpoint(&self, _cluster: &ClusterId) -> Option<String>
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".