pub struct TaskSharder { /* private fields */ }Expand description
Task-state sharding by stable task-ID hash (P2-9).
A 1000-agent fleet cannot keep every task in one store; this maps each task id to a shard so state is distributed deterministically and collocated lookups stay local.
Implementations§
Source§impl TaskSharder
impl TaskSharder
Sourcepub fn new(num_shards: usize) -> Self
pub fn new(num_shards: usize) -> Self
A sharder over num_shards shards (clamped to at least 1).
Sourcepub fn shards<'a>(
&self,
task_ids: impl IntoIterator<Item = &'a str>,
) -> Vec<usize>
pub fn shards<'a>( &self, task_ids: impl IntoIterator<Item = &'a str>, ) -> Vec<usize>
Shard assignments for many task ids, preserving order.
Sourcepub fn num_shards(&self) -> usize
pub fn num_shards(&self) -> usize
The number of shards.
Trait Implementations§
Source§impl Clone for TaskSharder
impl Clone for TaskSharder
Source§fn clone(&self) -> TaskSharder
fn clone(&self) -> TaskSharder
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 moreimpl Copy for TaskSharder
Auto Trait Implementations§
impl Freeze for TaskSharder
impl RefUnwindSafe for TaskSharder
impl Send for TaskSharder
impl Sync for TaskSharder
impl Unpin for TaskSharder
impl UnsafeUnpin for TaskSharder
impl UnwindSafe for TaskSharder
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