ulo
ulo
Documentation

Start here

Coming from NestJSNestJS topics, mapped

The model

Protocols

OverviewRPC controllersStreamingClientDeadlinesServerLinksTCPUDPNATSRedisRabbitMQMQTTKafka

Integrations

Operating

Reference

Microservices

RabbitMQ

The RabbitMQ link, a queue per pattern with reply_to, correlation_id and publisher confirms.

The RabbitMQ link speaks AMQP 0-9-1. Each pattern is a queue. A request reaches it through the default exchange and an event through the pattern's fanout exchange ulo.rpc.event.<pattern>. The payload is the body with AMQP headers, and replies come back through RabbitMQ's direct reply-to using reply_to and correlation_id.

app.bind(ulo_rpc::Server::new(ulo_rpc_rabbitmq::RabbitMq::url("amqp://guest:guest@mq:5672/%2f")));

Settings

MethodEffect
RabbitMq::url(url)amqp:// or amqps://
codec(Codec)JSON by default; Codec::Cbor carries raw bytes
connect_within(Duration)how long a server's listen and a client's connect wait for the broker. 30 seconds unset. A wait that runs out fails with ConnectTimedOut
with_handle(Handle)the tokio runtime, when the link is built outside one

A server's listen needs the app's Timer.

Behaviour

  • Handlers must be idempotent. Delivery is at least once: the ack is sent after the handler completes, so a request delivered again after a failure runs again. An unhandled event is rejected without requeue.
  • In-flight limit. One prefetch window serves every pattern and follows the server's max_inflight (1,024 unset, 64 under Count::Unlimited). A request over the bound waits in its queue instead of being refused.
  • Misses. The client publishes in confirm mode, a request with mandatory. A pattern whose queue no server ever declared is returned by the broker and maps to unavailable with the reason no_destination.
  • Queues outlive servers. A queue is neither auto-delete nor exclusive. A request sent while no instance is consuming waits in the queue for the next one, and its caller sees its own Timeout. The link holds unserved requests (the unserved_hold capability).
  • Events. An event is published to the fanout exchange ulo.rpc.event.<pattern>, which is bound to the pattern's shared queue, so one instance handles it. An event declared #[ulo_rpc::event("pattern", every_instance)] goes instead to an exclusive auto-delete queue of each instance's own, ulo.rpc.event.<pattern>.<uuid>, bound to the same exchange. Every running instance handles it, and an event emitted while none runs reaches none.
  • Name limits. AMQP caps an exchange name, a queue name, a routing key and a header name at 255 bytes. The link serves a pattern of at most 241 bytes, whose event exchange is then 255, and an every_instance event on a pattern of at most 208. A server refuses a longer pattern when it prepares, with one configuration failure naming each pattern, its length and the limit. A client fails a call before publishing when an exchange name, routing key or header name would pass the limit, with BadRequest and the reason name_too_long. The connection carries the frames after it.
  • Servers before clients. A client declares the pattern's exchange and publishes each event to it, and a queue is bound to the exchange once a server has declared the pattern. Until then the broker drops the client's events with no error at the client. Start the servers first. A server of ulo-rpc-rabbitmq 0.1.0-alpha.2 or earlier binds no queue to that exchange.
  • Ordering. Per queue, with a single consumer.
  • Lost connection. A call waiting when the client's connection drops fails Unavailable, since a direct reply-to address dies with its channel.
  • Streams. A streamed request opens with ulo-t: open and is answered ulo-t: opened. Items, end and cancel travel through the fanout exchange ulo.rpc.control, which binds one queue per server instance.
  • Drain. The server cancels its consumers (basic.cancel) and waits for each acknowledgement.
  • Connect limit. lapin cannot stop a connection that has not finished connecting. A listen that runs out against a broker that accepts the socket and never answers the handshake leaves one I/O thread and one socket until the process exits, so a supervisor retrying the start in-process against a silent broker leaks one of each per attempt.

Redis

The Redis link, Pub/Sub per pattern with the whole frame as the message.

MQTT

The MQTT v5 link, a topic per pattern with shared subscriptions, Response Topic and Correlation Data.

On this page

SettingsBehaviour