ulo
ulo
Documentation

Start here

Coming from NestJSNestJS topics, mapped

The model

Protocols

OverviewRPC controllersStreamingClientDeadlinesServerLinksTCPUDPNATSRedisRabbitMQMQTTKafka

Integrations

Operating

Reference

Microservices

TCP

The TCP link, frames multiplexed over one connection, with a tokio and a smol implementation.

The TCP link needs no broker. A server binds an address and a client connects to it. Examples 25, 26 and 27 use it.

app.bind(ulo_rpc::Server::new(ulo_rpc_tcp::Tcp::new("0.0.0.0:7000")));

Each frame is a 4-byte big-endian length followed by the frame. Calls are multiplexed by id over one connection, so one client connection carries any number of concurrent calls. Frames are ordered per connection. Every call shape is supported.

Settings

MethodEffect
Tcp::new(endpoint)text, a SocketAddr or an Endpoint. A server may listen on an inherited socket
tls(Tls)TLS on the server's endpoint, loaded when the server prepares, with no ALPN. Tls is ulo_net::Tls
codec(Codec)JSON by default; Codec::Cbor carries raw bytes
max_frame(bytes)the largest frame read or written. 1 MiB unset. A server holds the request frame of each call it admits, so its memory for frames is bounded by this times max_inflight, 1 GiB at the defaults. A payload larger than the limit needs max_frame raised on the server's link and the client's. Zero is refused
with_handle(Handle)the tokio runtime for the link's sockets and tasks, when it is built outside one

A frame over the limit

Of a larger frame the server reads the length prefix and the first 4 KiB, and the connection then ends. When the frame's leading bytes name a request, a streamed request's open or an item of a streamed request in flight, the server first answers that call BadRequest with the reason payload_too_large. A frame whose leading bytes name no call closes the connection with no answer.

Client limits

A client connects to an IP address and port such as 10.0.0.5:7000. The link resolves no host name, and a client given a host name is refused where it takes the link (RpcClient::new or connect). The client speaks plain TCP: a client built over a link with tls set is refused. TLS protects the server's side, for example for a client written for another stack.

Unhandled patterns

The server receives every frame, so it answers a pattern with no handler itself: unavailable, reason pattern_unhandled, message "no handler for pattern x". From examples/25-rpc-basics/tests/rpc.rs:

let error = client.request::<_, i64>("calc.nobody", &()).await.expect_err("refused");
assert_eq!((error.kind(), error.reason()), (ErrorKind::Unavailable, Some("pattern_unhandled")));

Shutdown

At the drain the listener closes and every connection, including one registered late, receives goaway. Calls in flight finish. A request that arrives afterwards on a connection the caller kept open is answered unavailable. A connection that closes cancels its calls in flight with the reason Disconnected. After close, connections read and discard what the peer still sends for up to two seconds, so a peer that is still writing receives the server's FIN rather than a reset.

ulo-rpc-tcp-smol

ulo_rpc_tcp_smol::Tcp is the same wire over async-net sockets, with futures-rustls for TLS, for apps on ulo_runtime_smol::Smol. No tokio is involved. A client of either link talks to a server of the other. with_runtime(runtime) puts the link's tasks on another runtime. The smol link has new, tls, codec and max_frame.

app.bind(ulo_rpc::Server::new(ulo_rpc_tcp_smol::Tcp::new("0.0.0.0:7000")));

ulo-rpc-tcp-core implements the wire both crates share. It is for link authors; an application depends on one of the two links.

Links

The same handlers over TCP, UDP, NATS, Redis, MQTT, RabbitMQ and Kafka, and what differs between the links.

UDP

The UDP link, one frame per datagram, for unary calls and events.

On this page

SettingsA frame over the limitClient limitsUnhandled patternsShutdownulo-rpc-tcp-smol