Skip to main content

ShardingHandle

Struct ShardingHandle 

Source
pub struct ShardingHandle { /* private fields */ }
Expand description

Running sharding region handle.

Implementations§

Source§

impl ShardingHandle

Source

pub fn node_id(&self) -> &str

Local cluster node id for this region.

Source

pub async fn register_entity_type<M, F, B>( &self, type_name: impl Into<String>, factory: F, ) -> ShardingResult<()>
where M: Serialize + DeserializeOwned + Send + 'static, F: Fn(EntityContext) -> B + Send + Sync + 'static, B: EntityBehavior<M>,

Register an entity type with a Ractor-backed factory.

Source

pub async fn register_actor_entity_type<M, F, A>( &self, type_name: impl Into<String>, factory: F, ) -> ShardingResult<()>
where M: Serialize + DeserializeOwned + Send + 'static, F: Fn(EntityContext) -> A + Send + Sync + 'static, A: ActorEntity<M>,

Register an entity type whose factory creates a spawnable actor entity.

The factory mirrors Akka Cluster Sharding’s EntityContext<M> => Behavior<M> boundary: it is invoked once for each entity incarnation, and ActorEntity::spawn returns the typed mailbox ingress used for routing M. Passivation and handoff stop that actor. A self-stopped actor remains stopped until the next delivery, which creates a new incarnation without retrying the message that caused the stop.

Source

pub async fn register_remembered_entity_type<M, F, B>( &self, type_name: impl Into<String>, factory: F, ) -> ShardingResult<()>
where M: Serialize + DeserializeOwned + Send + 'static, F: Fn(EntityContext) -> B + Send + Sync + 'static, B: EntityBehavior<M>,

Register an entity type with remember-entities enabled.

The region must be configured with RememberEntitiesConfig::with_store or registration fails. Remembered entities are spawned automatically when their shard starts locally after rebalance, restart recovery, or coordinator takeover. Passivation removes the id from the remember store; ordinary actor failure/restart and node stop do not.

Source

pub fn subscribe_remember_entities_events( &self, ) -> Receiver<RememberEntitiesEvent>

Subscribe to remember-entities store failure events.

Source

pub async fn flush_remember_entities(&self) -> ShardingResult<()>

Wait until previously queued remember-entities writes have been processed.

Source

pub fn entity_ref<M>( &self, type_name: impl Into<String>, entity_id: impl Into<String>, ) -> EntityRef<M>
where M: Serialize + Send + 'static,

Return an entity ref using the configured default extractor.

Source

pub fn entity_ref_with_extractor<M, E>( &self, type_name: impl Into<String>, entity_id: impl Into<String>, extractor: Arc<E>, ) -> EntityRef<M>
where M: Serialize + Send + 'static, E: ShardExtractor<M>,

Return an entity ref using a custom extractor.

Source

pub async fn allocation_table( &self, type_name: impl Into<String>, ) -> ShardingResult<ShardAllocationTable>

Return the cached allocation table known by this region.

Source

pub async fn rebalance_rounds(&self) -> ShardingResult<Vec<RebalanceRound>>

Return rebalance rounds recorded by this region when it was coordinator.

Source

pub async fn shutdown(&self)

Stop local sharding tasks. Dropping the cluster agent also clears the DCP provider.

Trait Implementations§

Source§

impl Clone for ShardingHandle

Source§

fn clone(&self) -> ShardingHandle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Message for T
where T: Any + Send + 'static,

Source§

fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>

Convert a BoxedMessage to this concrete type
Source§

fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>

Convert this message to a BoxedMessage
Source§

impl<T> OutputMessage for T
where T: Message + Clone,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> State for T
where T: Any + Send + 'static,

Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more