Expand description
Real-time protocol engine: WebSocket gateways + Server-Sent Events.
NestJS-Gateway ergonomics on a zero-cost, lock-free-on-the-hot-path Rust
core. Declare a gateway, subscribe to events, broadcast to rooms — without
ever naming an axum/tower type.
ⓘ
#[Injectable]
pub struct ChatGateway { db: Inject<Db> }
impl ArclyGateway for ChatGateway {
async fn on_connect(&self, client: WsClient) { client.join_room("lobby"); }
}
#[Gateway("/chat-socket")]
impl ChatGateway {
#[Subscribe("message::send")]
async fn on_message(&self, client: WsClient, payload: Json<ChatMessage>)
-> Result<(), Error>
{
client.broadcast_to_room(&payload.room, "message::receive", &*payload).await;
Ok(())
}
}See macros for the exact expansion contract and the rationale for the
#[Gateway]-on-impl placement.
Re-exports§
pub use connection::ConnId;pub use connection::ConnectionRegistry;pub use connection::WsClient;pub use connection::WsMessage;pub use gateway::ArclyGateway;pub use gateway::GatewayDescriptor;pub use gateway::GatewayRuntime;pub use gateway::LifecycleHook;pub use gateway::MessageHandler;pub use sse::SseEvent;pub use sse::SseStream;pub use ws::ws_route;
Modules§
- connection
- Lock-free connection & broadcasting registry.
- gateway
- Gateway contracts: the
ArclyGatewaylifecycle trait and the link-time descriptor / runtime types the#[Gateway]macro emits. - macros
- Registry glue for the real-time macro layer.
- sse
- High-performance Server-Sent Events engine.
- ws
- WebSocket boundary: upgrade, per-socket read/write pumps, event dispatch.