pub struct ShardSet { /* private fields */ }Expand description
The configured set of shards plus the routing strategy.
Cheap to clone (a single Arc). Available from
AppState::shards and through the
Shards extractor.
Implementations§
Source§impl ShardSet
impl ShardSet
Sourcepub const fn slot_count(&self) -> u16
pub const fn slot_count(&self) -> u16
Number of logical slots — the fixed SLOT_COUNT (16384).
Sourcepub fn slot_for_key<'k>(&self, key: impl Into<ShardKey<'k>>) -> SlotId
pub fn slot_for_key<'k>(&self, key: impl Into<ShardKey<'k>>) -> SlotId
Map a routing key onto its logical slot (deterministic hash; see the module docs for the permanence guarantee).
Sourcepub fn shard_for_slot(&self, slot: SlotId) -> Option<&Shard>
pub fn shard_for_slot(&self, slot: SlotId) -> Option<&Shard>
Owner of a logical slot per the configured slot map.
Sourcepub async fn route<'k>(
&self,
key: impl Into<ShardKey<'k>>,
) -> Result<&Shard, AutumnError>
pub async fn route<'k>( &self, key: impl Into<ShardKey<'k>>, ) -> Result<&Shard, AutumnError>
Resolve the shard that owns key via the installed
ShardRouter.
§Errors
Returns the router’s error, or an internal error if the router
produced an out-of-range ShardId.
Sourcepub fn total_max_connections(&self) -> usize
pub fn total_max_connections(&self) -> usize
Total configured max_size across every pool in the set
(primaries plus replicas). Logged at startup so N-shard
deployments notice multiplied connection counts.
Sourcepub fn owns_key<'k>(
&self,
shard_id: ShardId,
key: impl Into<ShardKey<'k>>,
) -> bool
pub fn owns_key<'k>( &self, shard_id: ShardId, key: impl Into<ShardKey<'k>>, ) -> bool
Whether key is owned by the shard at the given index in declaration order.
Uses the hash-based slot assignment, not the installed router (which may override routing for individual tenants via a directory). Use this for tooling / slot-move scripts where you need to verify ownership without issuing an async router call.
Sourcepub fn slots_for_shard(&self, shard_id: ShardId) -> Option<&[u16]>
pub fn slots_for_shard(&self, shard_id: ShardId) -> Option<&[u16]>
All logical slots assigned to the shard at index shard_id.
Returns None when the id is out of range.
Sourcepub fn partition_by_shard<'k>(
&self,
keys: impl IntoIterator<Item = &'k str>,
) -> HashMap<ShardId, Vec<&'k str>>
pub fn partition_by_shard<'k>( &self, keys: impl IntoIterator<Item = &'k str>, ) -> HashMap<ShardId, Vec<&'k str>>
Partition string keys by their owning shard based on hash-slot assignment.
Keys are grouped in declaration order; the returned map may have fewer
entries than self.len() when some shards own none of the given keys.
Useful for slot-move tooling that needs to issue WHERE tenant_id = ANY($1)
per destination shard.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ShardSet
impl !UnwindSafe for ShardSet
impl Freeze for ShardSet
impl Send for ShardSet
impl Sync for ShardSet
impl Unpin for ShardSet
impl UnsafeUnpin for ShardSet
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Source§impl<T> AutumnDependents for Twhere
T: ?Sized,
impl<T> AutumnDependents for Twhere
T: ?Sized,
Source§fn dependents() -> &'static [RuntimeDependentSpec]
fn dependents() -> &'static [RuntimeDependentSpec]
#[model] overrides via an inherent shadow when dependents exist.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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> RepositoryHooksClone for Twhere
T: Clone,
impl<T> RepositoryHooksClone for Twhere
T: Clone,
Source§fn autumn_clone(&self) -> T
fn autumn_clone(&self) -> T
Source§impl<T, Conn> RunQueryDsl<Conn> for T
impl<T, Conn> RunQueryDsl<Conn> for T
Source§fn execute<'conn, 'query>(
self,
conn: &'conn mut Conn,
) -> <Conn as AsyncConnectionCore>::ExecuteFuture<'conn, 'query>
fn execute<'conn, 'query>( self, conn: &'conn mut Conn, ) -> <Conn as AsyncConnectionCore>::ExecuteFuture<'conn, 'query>
Source§fn load<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
fn load<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
Source§fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnectionCore,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnectionCore,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
Stream] with the returned rows. Read moreSource§fn get_result<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, LoadNext<Pin<Box<Self::Stream<'conn>>>>>
fn get_result<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, LoadNext<Pin<Box<Self::Stream<'conn>>>>>
Source§fn get_results<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
fn get_results<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
Vec with the affected rows. Read moreSource§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.