SLIMRPC
SLIMRPC is Protocol Buffers RPC over SLIM. It is analogous to gRPC (which runs over HTTP/2), but uses the SLIM session layer as the transport. You define services in .proto files, generate language bindings with the SLIMRPC compiler, and interact with the generated stubs much like standard gRPC — while gaining SLIM's built-in security, reliable delivery, and end-to-end encryption.
Why SLIMRPC?
| gRPC | SLIMRPC | |
|---|---|---|
| Transport | HTTP/2 | SLIM sessions |
| Service discovery | External (DNS, load balancer) | Built into SLIM |
| End-to-end encryption | TLS (channel only) | MLS (application layer) |
| Multi-cloud / multi-cluster | Requires ingress / API gateway | Native SLIM routing |
| Streaming patterns | Unary, server-stream, client-stream, bidi | Same |
SLIM Naming
The server subscribes to a single SLIM name — its base identity. The service name and method are not encoded in the SLIM name; they travel as message metadata on each call.
For example, a server with SLIM name myorg/default/my-service handles every method of every service registered on it. The service and method metadata fields tell the server which handler to invoke:
| Metadata key | Example value |
|---|---|
service |
example_service.Test |
method |
ExampleUnaryUnary |
rpc-id |
d3f1a2b4-... (UUID-v4) |
slimrpc-dir |
req |
How It Works
Single Session, Many Calls
The SLIMRPC channel maintains one persistent SLIM session to the remote server. All concurrent RPC calls share that session — there is no per-method session negotiation.
Client Server
│ │
│── session establishment ───────────►│
│ │
│── [rpc-id=A, service=…, method=…] ─►│ ← first message of call A
│── [rpc-id=B, service=…, method=…] ─►│ ← first message of call B (concurrent)
│◄─ [rpc-id=A] ───────────────────────│ ← response to call A
│── [rpc-id=A] ──────────────────────►│ ← streaming continuation of call A
│◄─ [rpc-id=B] ───────────────────────│ ← response to call B
RPC ID and Multiplexing
Every call gets a unique RPC ID (UUID-v4) included in the first message. Subsequent messages in a streaming call carry only the rpc-id — the service and method are not repeated.
On the server, a per-session demultiplexer:
- Reads each message from the shared session
- Extracts the
rpc-id - If a handler exists for that
rpc-id(an in-progress streaming call), forwards the message to it - If no handler exists, reads
serviceandmethodto dispatch a new handler task
This allows many concurrent RPC calls — unary or streaming — to share a single SLIM session with no head-of-line blocking between calls.
Lazy Session Creation
The channel creates the SLIM session on the first RPC call and reuses it for all subsequent calls. If the session dies, the channel recreates it transparently on the next call.
Session Marker
Each session a channel opens carries slimrpc-session=1 in its metadata. A server takes every session on its name, so an app that also accepts plain sessions on that name reads its own session notifications and passes only the marked ones to the server. In Rust, is_slimrpc_session checks a new session for the marker.
Cancellation
A caller cancels a call by giving up on its response. The channel then sends a message with the call's rpc-id and slimrpc-dir=cancel, and the server stops that call's handler. Only the peer that made a call can cancel it. A server from a release without cancellation drops the message, and its handler runs until it finishes or reaches the call's deadline.
In Rust, giving up means:
- Unary-unary and stream-unary: abandoning the call while it waits for its response, for example when a timeout around it fires.
- Unary-stream and stream-stream: dropping the response stream before the server has ended it.
In the other languages, call cancel() on the object the call returns: the response reader of a unary-stream call, the request writer of a stream-unary call, or the handler of a stream-stream call, and the same for multicast calls. Responses already received can still be read. After them, the next read returns a Cancelled error, and sending fails. A unary-unary call has no such object; set a deadline instead.
Ending the request stream is not a cancel. It only tells the server that no more requests are coming (close_send on a stream-stream call). The server keeps running the call, and its responses can still be received. Dropping a whole channel closes its session, which stops every handler running on it.
Letting a response reader or a stream-stream handler go without calling cancel() also cancels the call, but not until the next response arrives, and the language's garbage collector decides when the object goes. A request writer that is let go only ends its requests.
Multicast RPC
A group channel fans out a single RPC call to multiple servers simultaneously. Create the channel with Channel.new_group_with_connection (or the language-specific equivalent), passing a list of server names. Responses arrive as an async stream of (context, response) pairs, one per server.
This is useful for broadcasting configuration, querying multiple services, or scatter-gather patterns.
Verified Peers
A readable name doesn't say who answers: any app trusted by your verifier can subscribe under it. To know, or require, the identity of the peers you call:
- See who answered (Rust only today).
Channel::peer_identity()returns the verified identity of a point-to-point channel's server. Themulticast_*_verifiedmethods yield each response with its sender's full name, id included, and the identity that member was verified as. - See who called. In a handler,
ctx.peer_subject()is the verified identity of the peer that sent the request: with MLS, the member that sent it, also in a group.ctx.peer_issuer()is its issuer (iss), when known. Both are available on the handler context in Rust, Python, Java, Kotlin, and Node.js (aspeerSubject()/peerIssuer()in Java, Kotlin, and Node.js). In Go, generated handlers read them from theircontext.Contextwithslim_rpc.PeerSubjectFromContext(ctx)/slim_rpc.PeerIssuerFromContext(ctx), which return("", false)when unknown; in .NET,SlimRpcContexthasPeerSubject/PeerIssuer,nullwhen unknown. - Require an identity (Rust only today).
Channel::new_pinnedandChannel::new_group_pinnedtake thesubeach peer must be verified as, its DID for adid:keyidentity. A peer verified as anyone else is never admitted, and the call fails.
Supported Languages
SLIMRPC code generation is supported for Python, Go, Java, Kotlin, .NET (C#), and Node.js / TypeScript. See the Compiler page for installation and usage. For .NET runtime details and the Agntcy.Slim.SlimRpc namespace, see the .NET SDK guide.
Tutorials
- Serving a SLIMRPC Server — define a proto, generate stubs, implement handlers, and serve
- Using a SLIMRPC Server — create a channel and call all four streaming patterns
- Multicast SLIMRPC — fan out a single call to multiple servers and collect their responses