arcly_http/realtime/mod.rs
1//! Real-time protocol engine: WebSocket gateways + Server-Sent Events.
2//!
3//! NestJS-Gateway ergonomics on a zero-cost, lock-free-on-the-hot-path Rust
4//! core. Declare a gateway, subscribe to events, broadcast to rooms — without
5//! ever naming an `axum`/`tower` type.
6//!
7//! ```ignore
8//! #[Injectable]
9//! pub struct ChatGateway { db: Inject<Db> }
10//!
11//! impl ArclyGateway for ChatGateway {
12//! async fn on_connect(&self, client: WsClient) { client.join_room("lobby"); }
13//! }
14//!
15//! #[Gateway("/chat-socket")]
16//! impl ChatGateway {
17//! #[Subscribe("message::send")]
18//! async fn on_message(&self, client: WsClient, payload: Json<ChatMessage>)
19//! -> Result<(), Error>
20//! {
21//! client.broadcast_to_room(&payload.room, "message::receive", &*payload).await;
22//! Ok(())
23//! }
24//! }
25//! ```
26//!
27//! See [`macros`] for the exact expansion contract and the rationale for the
28//! `#[Gateway]`-on-impl placement.
29
30pub mod connection;
31pub mod gateway;
32pub mod macros;
33pub mod sse;
34pub mod ws;
35
36pub use connection::{ConnId, ConnectionRegistry, WsClient, WsMessage};
37pub use gateway::{ArclyGateway, GatewayDescriptor, GatewayRuntime, LifecycleHook, MessageHandler};
38pub use sse::{SseEvent, SseStream};
39pub use ws::ws_route;
40
41// Re-export the procedural macros so users write `arcly_http::realtime::Gateway`.
42pub use arcly_http_macros::{Gateway, Subscribe};