Перейти к основному содержимому
Эта страница ещё не переведена

Ниже показан английский оригинал.

Errors

ZmqError is the one error type of the crate: endpoint, send, receive, wire, request timeout, not connected, invalid.

Each variant names the step that failed. The ZeroMQ client's own error is the source of Endpoint, so the client's types stay out of the crate's API.

VariantWhen
Endpointa socket could not bind or dial its address, such as a port another process holds at startup, or a peer that did not listen within 30 seconds
Senda message could not leave: a publish its own subscription would receive back, a publish to a peer that only sends, an answer to a requester that has gone, a header the text frame cannot carry, or no peer within five seconds
Receivean open subscription failed to receive
Wirea peer sent frames that do not follow the wire layout
RequestTimeouta request got no answer within its timeout
NotConnecteda publisher, a responder or a request was used after the broker shut down
Invalidan address with a scheme other than tcp:// or ipc://, or a second subscription on an endpoint the broker binds

A service meets the error in two places. A failed startup carries it as the source of the runtime's error, and the service exits before it reads anything. A publish from a handler returns it inside the core's PublishError, and the handler decides how the delivery settles. The enum is #[non_exhaustive], so a match on it ends with a wildcard arm.

Example​

A result the socket refuses is logged with its cause, and the job is settled as a retry in a second.

#[subscriber("jobs")]
async fn work(job: &Job, Out(results): Out<impl Publisher, Results>) -> HandlerOutcome {
if let Err(err) = results.message(&Done { id: job.id }).publish().await {
// The error names the destination and the socket's reason.
tracing::warn!(subscription = "jobs", job.id, error = %err, "result not published");
return HandlerOutcome::retry_after(Duration::from_secs(1));
}
HandlerOutcome::ack()
}