[][src]Struct libzmq::Gather

pub struct Gather { /* fields omitted */ }

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_high_water_mark(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"));
    }
}

Methods

impl Gather[src]

pub fn new() -> Result<Self, Error>[src]

pub fn with_ctx<C>(ctx: C) -> Result<Self, Error> where
    C: Into<Ctx>, 
[src]

Create a Gather socket from a specific context.

Returned Error Variants

pub fn ctx(&self) -> &Ctx[src]

Returns a reference to the context of the socket.

Trait Implementations

impl RecvMsg for Gather[src]

fn recv(&self, msg: &mut Msg) -> Result<(), Error>[src]

Retreive a message from the inbound socket queue. Read more

fn try_recv(&self, msg: &mut Msg) -> Result<(), Error>[src]

Try to retrieve a message from the inbound socket queue without blocking. Read more

fn recv_msg(&self) -> Result<Msg, Error>[src]

A convenience function that allocates a [Msg] with the same properties as [recv]. Read more

fn try_recv_msg(&self) -> Result<Msg, Error>[src]

A convenience function that allocates a [Msg] with the same properties as [try_recv]. Read more

fn recv_high_water_mark(&self) -> Result<Quantity, Error>[src]

The high water mark for incoming messages on the specified socket. Read more

fn set_recv_high_water_mark<Q>(&self, qty: Q) -> Result<(), Error> where
    Q: Into<Quantity>, 
[src]

Set the high water mark for inbound messages on the specified socket. Read more

fn recv_timeout(&self) -> Result<Period, Error>[src]

The timeout for [recv] on the socket. Read more

fn set_recv_timeout<P>(&self, period: P) -> Result<(), Error> where
    P: Into<Period>, 
[src]

Sets the timeout for [recv] on the socket. Read more

impl Socket for Gather[src]

fn connect<I, E>(&self, endpoints: I) -> Result<(), Error<usize>> where
    I: IntoIterator<Item = E>,
    E: Into<Endpoint>, 
[src]

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]

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]

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]

Set the socket's [Mechanism]. # Example ``` # use failure::Error; # # fn main() -> Result<(), Error> { use libzmq::{prelude::, Client, auth::}; Read more

fn heartbeat(&self) -> Option<Heartbeat>[src]

Returns a the socket's heartbeat configuration.

fn set_heartbeat(&self, maybe: Option<Heartbeat>) -> Result<(), Error>[src]

Set the socket's heartbeat configuration. Read more

impl Sync for Gather[src]

impl Eq for Gather[src]

impl Send for Gather[src]

impl PartialEq<Gather> for Gather[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl Clone for Gather[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a> From<&'a Gather> for Pollable<'a>[src]

impl Debug for Gather[src]

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]