2 releases
Uses new Rust 2024
| 0.1.1 | Mar 10, 2026 |
|---|---|
| 0.1.0 | Mar 10, 2026 |
#6 in #failover
Used in 2 crates
70KB
1.5K
SLoC
pushwire-server
Generic, multiplexed push server for real-time applications. Built on Axum with WebSocket and SSE transports.
Part of the pushwire protocol family.
Features
PushServer<C>— generic over yourChannelKind, register per-channel handlers- WebSocket + SSE — dual transport with
/rps(WebSocket),/rps/sse(SSE),/rps/ack(HTTP POST) - Cursor-based replay — clients resume after disconnect without message loss
- Priority queuing — high/normal/low lanes based on
ChannelKind::priority() - Auth validation — pluggable
AuthValidatorcallback on handshake - Binary assets — inline (base64) or pointer delivery with SHA-256 integrity
- Transport manager — Direct/P2P/Relay routing with automatic failover and backoff
- Relay controller — bandwidth-limited server-side relay with token-bucket rate limiting
- WebRTC signaling — optional peer-to-peer signaling relay (
rtcfeature)
Quick start
use pushwire_server::PushServer;
use std::sync::Arc;
// Define MyChannel implementing ChannelKind (see pushwire-core)
let server: Arc<PushServer<MyChannel>> = Arc::new(PushServer::new());
server.register_handler(MyChannel::Chat, |client_id, frame, server| {
// Echo to all connected clients
for id in server.connected_client_ids() {
let _ = server.send(id, frame.clone());
}
});
let app = server.clone().router();
let listener = tokio::net::TcpListener::bind("0.0.0.0:9100").await.unwrap();
axum::serve(listener, app.into_make_service()).await.unwrap();
Endpoints
| Route | Method | Description |
|---|---|---|
/rps |
GET (WebSocket upgrade) | Primary push channel — auth handshake, bidirectional frames |
/rps/sse |
GET | Server-Sent Events stream — ?client_id=...&channels=chat,system |
/rps/ack |
POST | HTTP acknowledgment — { client_id, channel, cursor } |
Feature flags
rtc(default) — enables WebRTC signaling relay viapushwire-core/rtc
License
Apache-2.0
Dependencies
~12–17MB
~238K SLoC