pub trait EndpointRole:
Sealed
+ Send
+ Sync
+ 'static { }Expand description
Which side of an endpoint this process takes: Bind or Connect.
The endpoint constructors fix it - ZmqEndpoint::bind and ZmqEndpoint::connect - and
every broker built on the endpoint carries it as its Role parameter, so ZmqQueue<Connect>
is a queue this process dials. The side decides where a retry copy of a one-way subscription
can go: a subscription that binds takes a copy sent to its own listener, while one that dials
reads from a peer that only sends, so its mount site names where the copies go.
Sealed: the two sides are the whole set.
§Examples
A service that builds every queue with the same settings, on whichever side the endpoint takes:
use ruststream_zeromq::EndpointRole;
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 }
}
fn queue<Role: EndpointRole>(endpoint: ZmqEndpoint<Role>) -> ZmqQueue<Role> {
ZmqQueue::new(endpoint).read_ahead(nonzero!(64_usize))
}
#[ruststream::app]
fn app() -> impl App {
let results = queue(ZmqEndpoint::connect("tcp://sink:5556")).bindable();
let to_results = results.bind(Publish);
RustStream::new(AppInfo::new("worker", "0.1.0"))
.with_broker(queue(ZmqEndpoint::bind("tcp://0.0.0.0:5555")), |b| {
b.include(work).out_reply(to_results);
})
.register_broker(results)
}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".