pub struct ShardHandle { /* private fields */ }Expand description
A cloneable handle for sending commands to a shard task.
Wraps the mpsc sender so callers don’t need to manage oneshot channels directly.
Implementations§
Source§impl ShardHandle
impl ShardHandle
Sourcepub async fn send(
&self,
request: ShardRequest,
) -> Result<ShardResponse, ShardError>
pub async fn send( &self, request: ShardRequest, ) -> Result<ShardResponse, ShardError>
Sends a request and waits for the response.
Returns ShardError::Unavailable if the shard task has stopped.
Sourcepub async fn dispatch(
&self,
request: ShardRequest,
) -> Result<Receiver<ShardResponse>, ShardError>
pub async fn dispatch( &self, request: ShardRequest, ) -> Result<Receiver<ShardResponse>, ShardError>
Sends a request and returns the reply channel without waiting
for the response. Used by Engine::broadcast to fan out to
all shards before collecting results, and by
Engine::dispatch_to_shard for the dispatch-collect pipeline.
Sourcepub async fn dispatch_reusable(
&self,
request: ShardRequest,
reply: Sender<ShardResponse>,
) -> Result<(), ShardError>
pub async fn dispatch_reusable( &self, request: ShardRequest, reply: Sender<ShardResponse>, ) -> Result<(), ShardError>
Sends a request using a caller-owned reply channel.
Unlike dispatch(), this doesn’t allocate a oneshot per call.
The caller reuses the same mpsc::Sender across commands, saving
a heap allocation per P=1 round-trip.
Sourcepub async fn dispatch_batch(
&self,
requests: Vec<ShardRequest>,
) -> Result<Vec<Receiver<ShardResponse>>, ShardError>
pub async fn dispatch_batch( &self, requests: Vec<ShardRequest>, ) -> Result<Vec<Receiver<ShardResponse>>, ShardError>
Sends a batch of requests as a single channel message.
Returns one receiver per request, in the same order. For a single
request, falls through to dispatch() to avoid the batch overhead.
This is the key optimization for pipelining: N commands targeting the same shard consume 1 channel slot instead of N.
Trait Implementations§
Source§impl Clone for ShardHandle
impl Clone for ShardHandle
Source§fn clone(&self) -> ShardHandle
fn clone(&self) -> ShardHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more