pub struct Scatter { /* private fields */ }
Expand description
A Scatter
socket is used to pipeline messages to workers.
Messages are round-robined to all connected Gather
sockets.
§Summary of Characteristics
Characteristic | Value |
---|---|
Compatible peer sockets | Gather |
Direction | Unidirectional |
Send/receive pattern | Send only |
Outgoing routing strategy | Round-robin |
Incoming routing strategy | Fair-queued |
Action in mute state | Block |
§Example
use libzmq::{prelude::*, *};
use std::time::Duration;
let addr = InprocAddr::new_unique();
// Our load balancing producer.
let lb = ScatterBuilder::new()
.bind(&addr)
.build()?;
let worker_a = GatherBuilder::new()
.connect(&addr)
.recv_hwm(1)
.recv_timeout(Duration::from_millis(100))
.build()?;
let worker_b = GatherBuilder::new()
.connect(&addr)
.recv_hwm(1)
.recv_timeout(Duration::from_millis(100))
.build()?;
// Send messages to workers in a round-robin fashion.
lb.send("")?;
lb.send("")?;
assert!(worker_a.recv_msg()?.is_empty());
assert!(worker_b.recv_msg()?.is_empty());
Implementations§
Trait Implementations§
Source§impl Heartbeating for Scatter
impl Heartbeating for Scatter
Source§impl SendMsg for Scatter
impl SendMsg for Scatter
Source§fn send<M>(&self, msg: M) -> Result<(), Error<Msg>>
fn send<M>(&self, msg: M) -> Result<(), Error<Msg>>
Push a message into the outgoing socket queue. Read more
Source§fn try_send<M>(&self, msg: M) -> Result<(), Error<Msg>>
fn try_send<M>(&self, msg: M) -> Result<(), Error<Msg>>
Try to push a message into the outgoing socket queue without blocking. Read more
Source§fn send_hwm(&self) -> Result<i32, Error>
fn send_hwm(&self) -> Result<i32, Error>
The high water mark for outbound messages on the specified socket. Read more
Source§fn set_send_hwm(&self, hwm: i32) -> Result<(), Error>
fn set_send_hwm(&self, hwm: i32) -> Result<(), Error>
Set the high water mark for outbound messages on the specified socket. Read more
Source§impl Socket for Scatter
impl Socket for Scatter
impl Eq for Scatter
impl Send for Scatter
impl Sync for Scatter
Auto Trait Implementations§
impl Freeze for Scatter
impl RefUnwindSafe for Scatter
impl Unpin for Scatter
impl UnwindSafe for Scatter
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