[−][src]Struct libzmq::Gather
A Gather
socket is used to receive pipelined messages.
Messages are fair-queued from among all connected Scatter
sockets.
Summary of Characteristics
Characteristic | Value |
---|---|
Compatible peer sockets | Scatter |
Direction | Unidirectional |
Send/receive pattern | Receive only |
Outgoing routing strategy | Round-robin |
Incoming routing strategy | Fair-queued |
Action in mute state | Block |
Example
use libzmq::{prelude::*, *}; let addr_a = InprocAddr::new_unique(); let addr_b = InprocAddr::new_unique(); // Create our two load balancers. let lb_a = ScatterBuilder::new() .bind(&addr_a) .build()?; let lb_b = ScatterBuilder::new() .bind(&addr_b) .build()?; // Connect the worker to both load balancers. let worker = GatherBuilder::new() .connect(&[addr_a, addr_b]) .recv_hwm(1) .build()?; for _ in 0..100 { lb_a.try_send("a")?; } for _ in 0..100 { lb_b.try_send("b")?; } // The messages received should be fair-queues from // our two load balancers. let mut msg = Msg::new(); for i in 0..200 { worker.try_recv(&mut msg)?; if i % 2 == 0 { assert_eq!(msg.to_str(), Ok("a")); } else { assert_eq!(msg.to_str(), Ok("b")); } }
Implementations
impl Gather
[src]
pub fn new() -> Result<Self, Error>
[src]
pub fn with_ctx(handle: CtxHandle) -> Result<Self, Error>
[src]
Create a Gather
socket associated with a specific context
from a CtxHandle
.
Returned Error Variants
pub fn ctx(&self) -> CtxHandle
[src]
Returns a handle to the context of the socket.
Trait Implementations
impl Clone for Gather
[src]
impl Debug for Gather
[src]
impl Eq for Gather
[src]
impl<'a> From<&'a Gather> for Pollable<'a>
[src]
impl Heartbeating for Gather
[src]
fn heartbeat(&self) -> Option<Heartbeat>
[src]
fn set_heartbeat(&self, maybe: Option<Heartbeat>) -> Result<(), Error>
[src]
impl PartialEq<Gather> for Gather
[src]
impl RecvMsg for Gather
[src]
fn recv(&self, msg: &mut Msg) -> Result<(), Error>
[src]
fn try_recv(&self, msg: &mut Msg) -> Result<(), Error>
[src]
fn recv_msg(&self) -> Result<Msg, Error>
[src]
fn try_recv_msg(&self) -> Result<Msg, Error>
[src]
fn recv_hwm(&self) -> Result<i32, Error>
[src]
fn set_recv_hwm(&self, hwm: i32) -> Result<(), Error>
[src]
fn recv_timeout(&self) -> Result<Period, Error>
[src]
fn set_recv_timeout<P>(&self, period: P) -> Result<(), Error> where
P: Into<Period>,
[src]
P: Into<Period>,
impl Send for Gather
[src]
impl Socket for Gather
[src]
fn connect<E>(&self, endpoint: E) -> Result<(), Error> where
E: Into<Endpoint>,
[src]
E: Into<Endpoint>,
fn bind<E>(&self, endpoint: E) -> Result<(), Error> where
E: Into<Endpoint>,
[src]
E: Into<Endpoint>,
fn disconnect<E>(&self, endpoint: E) -> Result<(), Error> where
E: Into<Endpoint>,
[src]
E: Into<Endpoint>,
fn unbind<I, E>(&self, endpoint: E) -> Result<(), Error> where
E: Into<Endpoint>,
[src]
E: Into<Endpoint>,
fn last_endpoint(&self) -> Result<Endpoint, Error>
[src]
fn mechanism(&self) -> Mechanism
[src]
fn set_mechanism<M>(&self, mechanism: M) -> Result<(), Error> where
M: Into<Mechanism>,
[src]
M: Into<Mechanism>,
impl Sync for Gather
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &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> 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, 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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,