pub struct FieldHashBucketRouting<M, T, H>{ /* private fields */ }Expand description
A router using consistent hashing on some field of the message
Changing the membership is supported, but will result in bucket reassignments.
Implementations§
Source§impl<M, T, H> FieldHashBucketRouting<M, T, H>
impl<M, T, H> FieldHashBucketRouting<M, T, H>
Sourcepub fn new(
hasher_builder: H,
field_extractor: fn(&M) -> &T,
) -> FieldHashBucketRouting<M, T, H>
pub fn new( hasher_builder: H, field_extractor: fn(&M) -> &T, ) -> FieldHashBucketRouting<M, T, H>
Create a new instance of this router using the provided hasher and field extractor function
Sourcepub fn hash_field(&self, field: &T) -> u64
pub fn hash_field(&self, field: &T) -> u64
Hashes the field using this router’s Hasher
Sourcepub fn hash_message(&self, msg: &M) -> u64
pub fn hash_message(&self, msg: &M) -> u64
Extracts and hashes the msg field using this router’s Hasher
Sourcepub fn get_bucket(&self, msg: &M, length: usize) -> usize
pub fn get_bucket(&self, msg: &M, length: usize) -> usize
Provides the bucket index for the msg for length buckets
It does so by calling hash_message internally and then using modulo arithmentic to decide a bucket from the hash.
Trait Implementations§
Source§impl<M, T, H> Clone for FieldHashBucketRouting<M, T, H>
impl<M, T, H> Clone for FieldHashBucketRouting<M, T, H>
Source§fn clone(&self) -> FieldHashBucketRouting<M, T, H>
fn clone(&self) -> FieldHashBucketRouting<M, T, H>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<M, T, H> Debug for FieldHashBucketRouting<M, T, H>
impl<M, T, H> Debug for FieldHashBucketRouting<M, T, H>
Source§impl<H> Default for FieldHashBucketRouting<NetMessage, ActorPath, H>
impl<H> Default for FieldHashBucketRouting<NetMessage, ActorPath, H>
Source§fn default() -> FieldHashBucketRouting<NetMessage, ActorPath, H>
fn default() -> FieldHashBucketRouting<NetMessage, ActorPath, H>
Returns the “default value” for a type. Read more
Source§impl<H> RoutingPolicy<DynActorRef, NetMessage> for FieldHashBucketRouting<NetMessage, ActorPath, H>
impl<H> RoutingPolicy<DynActorRef, NetMessage> for FieldHashBucketRouting<NetMessage, ActorPath, H>
Source§fn route(
&self,
members: &[&DynActorRef],
msg: NetMessage,
logger: &Logger<Arc<Fuse<Async>>>,
)
fn route( &self, members: &[&DynActorRef], msg: NetMessage, logger: &Logger<Arc<Fuse<Async>>>, )
Source§fn boxed_clone(
&self,
) -> Box<dyn RoutingPolicy<DynActorRef, NetMessage> + Send + Sync>
fn boxed_clone( &self, ) -> Box<dyn RoutingPolicy<DynActorRef, NetMessage> + Send + Sync>
Create a boxed copy of this policy Read more
Source§fn broadcast(
&self,
) -> Option<&(dyn RoutingPolicy<DynActorRef, NetMessage> + Send + Sync)>
fn broadcast( &self, ) -> Option<&(dyn RoutingPolicy<DynActorRef, NetMessage> + Send + Sync)>
Provide the broadcast part of this policy, if any
Source§fn select(
&self,
) -> Option<&(dyn RoutingPolicy<DynActorRef, NetMessage> + Send + Sync)>
fn select( &self, ) -> Option<&(dyn RoutingPolicy<DynActorRef, NetMessage> + Send + Sync)>
Provide the select part of this policy, if any
impl<M, T, H> Copy for FieldHashBucketRouting<M, T, H>
Auto Trait Implementations§
impl<M, T, H> Freeze for FieldHashBucketRouting<M, T, H>where
H: Freeze,
impl<M, T, H> RefUnwindSafe for FieldHashBucketRouting<M, T, H>where
H: RefUnwindSafe,
impl<M, T, H> Send for FieldHashBucketRouting<M, T, H>where
H: Send,
impl<M, T, H> Sync for FieldHashBucketRouting<M, T, H>where
H: Sync,
impl<M, T, H> Unpin for FieldHashBucketRouting<M, T, H>where
H: Unpin,
impl<M, T, H> UnsafeUnpin for FieldHashBucketRouting<M, T, H>where
H: UnsafeUnpin,
impl<M, T, H> UnwindSafe for FieldHashBucketRouting<M, T, H>where
H: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more