Skip to content

Commit a58ed70

Browse files
committed
feat(rpc): extract native agntcy-slim-rpc crate from the FFI bindings
SlimRPC (the gRPC-like RPC framework over SLIM) was implemented only inside the UniFFI bindings crate (agntcy/slim-bindings), forcing every Rust consumer (a2a-slimrpc, and transitively SHADI) to depend on the FFI shim to speak SlimRPC. Move the native engine into this repo as agntcy-slim-rpc. Decoupling from the FFI crate: strip 37 UniFFI annotations; provide a self-contained runtime module for the blocking convenience wrappers; use native App<AuthProvider, AuthVerifier> / ProtoName instead of the FFI wrapper types; drop the Server::new convenience constructors that derived the notification receiver from the App wrapper (native entry point is new_with_shared_rx_and_connection). See crates/rpc/DESIGN.md. Follow-ups (separate PRs): rewire slim-bindings' slimrpc to wrap this crate; repoint a2a-slimrpc onto it. Signed-off-by: Luca Muscariello <muscariello@ieee.org>
1 parent 580208b commit a58ed70

14 files changed

Lines changed: 5535 additions & 0 deletions

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ members = [
1010
"crates/examples",
1111
"crates/mls",
1212
"crates/proto",
13+
"crates/rpc",
1314
"crates/service",
1415
"crates/session",
1516
"crates/signal",
@@ -46,6 +47,7 @@ agntcy-slim-controller = { path = "crates/controller", version = "0.10.0" }
4647
agntcy-slim-datapath = { path = "crates/datapath", version = "0.16.1" }
4748
agntcy-slim-mls = { path = "crates/mls", version = "0.2.1" }
4849
agntcy-slim-proto = { path = "crates/proto", version = "0.2.0" }
50+
agntcy-slim-rpc = { path = "crates/rpc", version = "0.1.0" }
4951
agntcy-slim-service = { path = "crates/service", version = "0.11.0", default-features = false }
5052
agntcy-slim-session = { path = "crates/session", version = "0.5.0" }
5153
agntcy-slim-signal = { path = "crates/signal", version = "0.1.10" }

crates/rpc/Cargo.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright AGNTCY Contributors (https://github.com/agntcy)
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
[package]
5+
name = "agntcy-slim-rpc"
6+
edition = { workspace = true }
7+
license = { workspace = true }
8+
version = "0.1.0"
9+
description = "SlimRPC: a gRPC-like RPC framework over SLIM (native Rust)."
10+
11+
[lib]
12+
name = "slim_rpc"
13+
14+
[dependencies]
15+
agntcy-slim-auth = { workspace = true }
16+
agntcy-slim-datapath = { workspace = true }
17+
agntcy-slim-service = { workspace = true, features = ["session"] }
18+
agntcy-slim-session = { workspace = true }
19+
async-stream = { workspace = true }
20+
async-trait = { workspace = true }
21+
display-error-chain = { workspace = true }
22+
drain = { workspace = true }
23+
futures = { workspace = true }
24+
futures-timer = { workspace = true }
25+
parking_lot = { workspace = true }
26+
thiserror = { workspace = true }
27+
tokio = { workspace = true }
28+
tokio-stream = { workspace = true }
29+
tracing = { workspace = true }
30+
uuid = { workspace = true }

crates/rpc/DESIGN.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# agntcy-slim-rpc — design note
2+
3+
## Why this crate exists
4+
5+
SlimRPC (the gRPC-like RPC framework over SLIM) was implemented **only inside the
6+
UniFFI bindings repo** (`agntcy/slim-bindings`, `rust/src/slimrpc*`). That crate
7+
is the FFI adapter for foreign languages (Go/Swift/Kotlin). Because the RPC engine
8+
lived there, every **Rust** consumer — `a2a-slimrpc`, and transitively SHADI — was
9+
forced to depend on the UniFFI shim just to speak SlimRPC.
10+
11+
This crate moves the **native Rust engine** into `agntcy/slim` where it belongs.
12+
`slim-bindings` becomes a thin UniFFI wrapper over it (follow-up, separate repo).
13+
14+
## What was extracted
15+
16+
The `slimrpc.rs` module + `slimrpc/` submodules (`channel`, `server`, `context`,
17+
`error`, `codec`, `rpc_session`, `session_wrapper`, `handler_traits`,
18+
`stream_types`) — ~5,500 LOC. The engine already worked directly on native types
19+
(`slim_service::app::App`, `slim_datapath::api::ProtoName`, `slim_session::*`).
20+
21+
## Decoupling from the FFI crate
22+
23+
- **UniFFI removed** — 37 annotations (`#[uniffi::export]`, `uniffi::Object/Record/Enum/Error`, …) stripped. The FFI surface belongs in `slim-bindings`.
24+
- **`get_runtime()`** — was a global in the bindings crate; now a self-contained `runtime` module here (for the blocking convenience wrappers; async callers use the `*_async` methods).
25+
- **`crate::App` / `crate::Name`** — the bindings' FFI wrapper types are replaced with the native `App<AuthProvider, AuthVerifier>` and `ProtoName`.
26+
- **`Server::new` / `new_with_connection`** — dropped. They derived the notification receiver from the App *wrapper* (`app.notification_receiver()`), which native `App` doesn't expose. The native entry point is `Server::new_with_shared_rx_and_connection` (explicit rx). The convenience wrappers move to `slim-bindings`.
27+
28+
## Follow-ups (separate PRs)
29+
30+
1. `agntcy/slim-bindings`: replace its `slimrpc` module with a thin UniFFI wrapper that depends on `agntcy-slim-rpc`.
31+
2. `a2aproject/a2a-rs`: repoint `a2a-slimrpc` off `slim_bindings` onto `agntcy-slim-rpc` + native `App`/`Name`.

0 commit comments

Comments
 (0)