Struct Scatter

Source
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

CharacteristicValue
Compatible peer socketsGather
DirectionUnidirectional
Send/receive patternSend only
Outgoing routing strategyRound-robin
Incoming routing strategyFair-queued
Action in mute stateBlock

§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§

Source§

impl Scatter

Source

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

Create a Scatter socket from the global context

§Returned Error Variants
Source

pub fn with_ctx(handle: CtxHandle) -> Result<Self, Error>

Create a Scatter socket associated with a specific context from a CtxHandle.

§Returned Error Variants
Source

pub fn ctx(&self) -> CtxHandle

Returns a handle to the context of the socket.

Trait Implementations§

Source§

impl Clone for Scatter

Source§

fn clone(&self) -> Scatter

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Scatter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a Scatter> for Pollable<'a>

Source§

fn from(scatter: &'a Scatter) -> Self

Converts to this type from the input type.
Source§

impl Heartbeating for Scatter

Source§

fn heartbeat(&self) -> Option<Heartbeat>

Returns a the socket’s heartbeating configuration.
Source§

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

Sets the socket’s heartbeating configuration.
Source§

impl PartialEq for Scatter

Source§

fn eq(&self, other: &Scatter) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl SendMsg for Scatter

Source§

fn send<M>(&self, msg: M) -> Result<(), Error<Msg>>
where M: Into<Msg>,

Push a message into the outgoing socket queue. Read more
Source§

fn try_send<M>(&self, msg: M) -> Result<(), Error<Msg>>
where M: Into<Msg>,

Try to push a message into the outgoing socket queue without blocking. Read more
Source§

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>

Set the high water mark for outbound messages on the specified socket. Read more
Source§

fn send_timeout(&self) -> Result<Period, Error>

Sets the timeout for [send] on the socket. Read more
Source§

fn set_send_timeout<P>(&self, period: P) -> Result<(), Error>
where P: Into<Period>,

Sets the timeout for [send] on the socket. Read more
Source§

impl Socket for Scatter

Source§

fn connect<E>(&self, endpoint: E) -> Result<(), Error>
where E: Into<Endpoint>,

Schedules a connection to a Endpoint. Read more
Source§

fn bind<E>(&self, endpoint: E) -> Result<(), Error>
where E: Into<Endpoint>,

Schedules a bind to a Endpoint and then accepts incoming connections. Read more
Source§

fn disconnect<E>(&self, endpoint: E) -> Result<(), Error>
where E: Into<Endpoint>,

Disconnect the socket from a Endpoint. Read more
Source§

fn unbind<I, E>(&self, endpoint: E) -> Result<(), Error>
where E: Into<Endpoint>,

Unbind the socket from a Endpoint. Read more
Source§

fn last_endpoint(&self) -> Result<Endpoint, Error>

Retrieve the last endpoint connected or bound to. Read more
Source§

fn mechanism(&self) -> Mechanism

Returns the socket’s Mechanism. Read more
Source§

fn set_mechanism<M>(&self, mechanism: M) -> Result<(), Error>
where M: Into<Mechanism>,

Set the socket’s Mechanism. Read more
Source§

impl Eq for Scatter

Source§

impl Send for Scatter

Source§

impl Sync for Scatter

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.