pub struct ZmqEndpoint<Role = Bind> { /* private fields */ }Expand description
An address (tcp://... or ipc://...) and the side of it this process takes, fixed by the
constructor and carried in the type.
§Examples
A worker that listens for jobs from a producer on the same host and pushes its results to a collector it dials over the network:
use ruststream_zeromq::queue::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
struct Job {
id: u64,
}
#[derive(Serialize, Outgoing)]
#[outgoing(name = "results")]
struct Done {
id: u64,
}
#[subscriber("jobs", reply)]
async fn work(job: &Job) -> Done {
Done { id: job.id }
}
#[ruststream::app]
fn app() -> impl App {
let collector = ZmqQueue::new(ZmqEndpoint::connect("tcp://collector:5560")).bindable();
let results = collector.bind(Publish);
RustStream::new(AppInfo::new("worker", "0.1.0"))
.with_broker(ZmqQueue::new(ZmqEndpoint::bind("ipc:///tmp/jobs")), |b| {
b.include(work).out_reply(results);
})
.register_broker(collector)
}Implementations§
Source§impl ZmqEndpoint<Bind>
impl ZmqEndpoint<Bind>
Sourcepub fn bind(address: impl Into<String>) -> Self
pub fn bind(address: impl Into<String>) -> Self
This process listens on address.
§Examples
A worker that listens on a local socket for the producers on its host:
use ruststream_zeromq::queue::prelude::*;
use serde::Deserialize;
#[derive(Deserialize)]
struct Job {
id: u64,
}
#[subscriber("jobs")]
async fn work(job: &Job) -> HandlerOutcome {
tracing::info!(job.id, "working on the job");
HandlerOutcome::ack()
}
#[ruststream::app]
fn app() -> impl App {
RustStream::new(AppInfo::new("worker", "0.1.0")).with_broker(
ZmqQueue::new(ZmqEndpoint::bind("ipc:///tmp/jobs")),
|b| {
b.include(work);
},
)
}Source§impl ZmqEndpoint<Connect>
impl ZmqEndpoint<Connect>
Sourcepub fn connect(address: impl Into<String>) -> Self
pub fn connect(address: impl Into<String>) -> Self
This process dials out to address.
§Examples
A worker that pushes its results to the collector it dials:
use ruststream_zeromq::queue::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
struct Job {
id: u64,
}
#[derive(Serialize, Outgoing)]
#[outgoing(name = "results")]
struct Done {
id: u64,
}
#[subscriber("jobs", reply)]
async fn work(job: &Job) -> Done {
Done { id: job.id }
}
#[ruststream::app]
fn app() -> impl App {
let collector = ZmqQueue::new(ZmqEndpoint::connect("tcp://collector:5560")).bindable();
let results = collector.bind(Publish);
RustStream::new(AppInfo::new("worker", "0.1.0"))
.with_broker(ZmqQueue::new(ZmqEndpoint::bind("tcp://0.0.0.0:5555")), |b| {
b.include(work).out_reply(results);
})
.register_broker(collector)
}Source§impl<Role> ZmqEndpoint<Role>
impl<Role> ZmqEndpoint<Role>
Sourcepub fn address(&self) -> &str
pub fn address(&self) -> &str
The address string.
§Examples
A worker that logs where it listens before it starts:
use ruststream_zeromq::queue::prelude::*;
use serde::Deserialize;
#[derive(Deserialize)]
struct Job {
id: u64,
}
#[subscriber("jobs")]
async fn work(job: &Job) -> HandlerOutcome {
tracing::info!(job.id, "working on the job");
HandlerOutcome::ack()
}
#[ruststream::app]
fn app() -> impl App {
let endpoint = ZmqEndpoint::bind("tcp://0.0.0.0:5555");
tracing::info!(address = endpoint.address(), "worker listening");
RustStream::new(AppInfo::new("worker", "0.1.0"))
.with_broker(ZmqQueue::new(endpoint), |b| {
b.include(work);
})
}Trait Implementations§
Source§impl<Role: Clone> Clone for ZmqEndpoint<Role>
impl<Role: Clone> Clone for ZmqEndpoint<Role>
Source§impl<Role: Debug> Debug for ZmqEndpoint<Role>
impl<Role: Debug> Debug for ZmqEndpoint<Role>
impl<Role: Eq> Eq for ZmqEndpoint<Role>
Source§impl<Role: PartialEq> PartialEq for ZmqEndpoint<Role>
impl<Role: PartialEq> PartialEq for ZmqEndpoint<Role>
impl<Role: PartialEq> StructuralPartialEq for ZmqEndpoint<Role>
Auto Trait Implementations§
impl<Role> Freeze for ZmqEndpoint<Role>where
PhantomData<Role>: Freeze,
impl<Role> RefUnwindSafe for ZmqEndpoint<Role>where
PhantomData<Role>: RefUnwindSafe,
impl<Role> Send for ZmqEndpoint<Role>where
PhantomData<Role>: Send,
impl<Role> Sync for ZmqEndpoint<Role>where
PhantomData<Role>: Sync,
impl<Role> Unpin for ZmqEndpoint<Role>where
PhantomData<Role>: Unpin,
impl<Role> UnsafeUnpin for ZmqEndpoint<Role>where
PhantomData<Role>: UnsafeUnpin,
impl<Role> UnwindSafe for ZmqEndpoint<Role>where
PhantomData<Role>: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compares
self with key and returns true if they are equal.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