[−][src]Struct libzmq::Scatter
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_high_water_mark(1) .recv_timeout(Duration::from_millis(100)) .build()?; let worker_b = GatherBuilder::new() .connect(&addr) .recv_high_water_mark(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());
Methods
impl Scatter
[src]
pub fn new() -> Result<Self, Error>
[src]
pub fn with_ctx<C>(ctx: C) -> Result<Self, Error> where
C: Into<Ctx>,
[src]
C: Into<Ctx>,
pub fn ctx(&self) -> &Ctx
[src]
Returns a reference to the context of the socket.
Trait Implementations
impl Heartbeating for Scatter
[src]
fn heartbeat(&self) -> Option<Heartbeat>
[src]
Returns a the socket's heartbeating configuration.
fn set_heartbeat(&self, maybe: Option<Heartbeat>) -> Result<(), Error>
[src]
Sets the socket's heartbeating configuration.
impl SendMsg for Scatter
[src]
fn send<M>(&self, msg: M) -> Result<(), Error<Msg>> where
M: Into<Msg>,
[src]
M: Into<Msg>,
Push a message into the outgoing socket queue. Read more
fn try_send<M>(&self, msg: M) -> Result<(), Error<Msg>> where
M: Into<Msg>,
[src]
M: Into<Msg>,
Try to push a message into the outgoing socket queue without blocking. Read more
fn send_high_water_mark(&self) -> Result<Quantity, Error>
[src]
The high water mark for outbound messages on the specified socket. Read more
fn set_send_high_water_mark<Q>(&self, qty: Q) -> Result<(), Error> where
Q: Into<Quantity>,
[src]
Q: Into<Quantity>,
Set the high water mark for outbound messages on the specified socket. Read more
fn send_timeout(&self) -> Result<Period, Error>
[src]
Sets the timeout for [send
] on the socket. Read more
fn set_send_timeout<P>(&self, period: P) -> Result<(), Error> where
P: Into<Period>,
[src]
P: Into<Period>,
Sets the timeout for [send
] on the socket. Read more
impl Socket for Scatter
[src]
fn connect<I, E>(&self, endpoints: I) -> Result<(), Error<usize>> where
I: IntoIterator<Item = E>,
E: Into<Endpoint>,
[src]
I: IntoIterator<Item = E>,
E: Into<Endpoint>,
Schedules a connection to one or more [Endpoints
] and then accepts incoming connections. Read more
fn bind<I, E>(&self, endpoints: I) -> Result<(), Error<usize>> where
I: IntoIterator<Item = E>,
E: Into<Endpoint>,
[src]
I: IntoIterator<Item = E>,
E: Into<Endpoint>,
Schedules a bind to one or more [Endpoints
] and then accepts incoming connections. Read more
fn disconnect<I, E>(&self, endpoints: I) -> Result<(), Error<usize>> where
I: IntoIterator<Item = E>,
E: Into<Endpoint>,
[src]
I: IntoIterator<Item = E>,
E: Into<Endpoint>,
Disconnect the socket from one or more [Endpoints
]. Read more
fn last_endpoint(&self) -> Result<Option<Endpoint>, Error>
[src]
Retrieve the last endpoint connected or bound to. Read more
fn mechanism(&self) -> Mechanism
[src]
Returns the socket's [Mechanism
]. Read more
fn set_mechanism<M>(&self, mechanism: M) -> Result<(), Error> where
M: Into<Mechanism>,
[src]
M: Into<Mechanism>,
Set the socket's [Mechanism
]. # Example ``` # use failure::Error; # # fn main() -> Result<(), Error> { use libzmq::{prelude::, Client, auth::}; Read more
impl Send for Scatter
[src]
impl PartialEq<Scatter> for Scatter
[src]
fn eq(&self, other: &Scatter) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Eq for Scatter
[src]
impl Sync for Scatter
[src]
impl<'a> From<&'a Scatter> for Pollable<'a>
[src]
impl Clone for Scatter
[src]
fn clone(&self) -> Scatter
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Scatter
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,