pub struct ZmqSubscriber { /* private fields */ }Expand description
A subscription on one of the one-way patterns - PUSH/PULL or PUB/SUB - yielding
ZmqMessages singly or in batches.
A receive on a socket yields one multipart message, so a batch is collected on this side: it closes once it holds the size the mount named, or 20 ms after its first delivery, whichever comes first. The 20 ms is a constant of this crate.
§Examples
A handler that takes a slice receives a whole batch, and the mount site caps its size:
use ruststream_zeromq::queue::prelude::*;
use serde::Deserialize;
#[derive(Deserialize)]
struct Job {
id: u64,
}
#[subscriber("jobs")]
async fn drain(jobs: &[Job]) -> HandlerOutcome {
tracing::info!(size = jobs.len(), "working on a batch");
HandlerOutcome::ack()
}
#[ruststream::app]
fn app() -> impl App {
RustStream::new(AppInfo::new("worker", "0.1.0")).with_broker(
ZmqQueue::new(ZmqEndpoint::bind("tcp://0.0.0.0:5555")),
|b| {
b.include(drain.batch(nonzero!(32)));
},
)
}Trait Implementations§
Source§impl BatchSubscriber for ZmqSubscriber
The transport has no batches of its own - a receive yields one multipart message - so they are
assembled on the client, to the size the registration named. The deadline that closes a partial
batch is the crate’s own (20 ms); the size is not, it arrives per subscription.
impl BatchSubscriber for ZmqSubscriber
The transport has no batches of its own - a receive yields one multipart message - so they are assembled on the client, to the size the registration named. The deadline that closes a partial batch is the crate’s own (20 ms); the size is not, it arrives per subscription.
Source§type Batch = Vec<ZmqMessage>
type Batch = Vec<ZmqMessage>
Container yielded by
batches. Implementations choose between Vec, custom
iterators, or anything else that yields the underlying Subscriber::Message.Source§impl Debug for ZmqSubscriber
impl Debug for ZmqSubscriber
Source§impl Subscriber for ZmqSubscriber
impl Subscriber for ZmqSubscriber
Source§type Message = ZmqMessage
type Message = ZmqMessage
The message type yielded by this subscriber.
Auto Trait Implementations§
impl Freeze for ZmqSubscriber
impl RefUnwindSafe for ZmqSubscriber
impl Send for ZmqSubscriber
impl Sync for ZmqSubscriber
impl Unpin for ZmqSubscriber
impl UnsafeUnpin for ZmqSubscriber
impl UnwindSafe for ZmqSubscriber
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more