Skip to main content

Crate rifts

Crate rifts 

Source
Expand description

§Rifts — Rift Realtime Protocol / 1.0 Server Implementation

This crate implements the server-side of the Rift Realtime Protocol v1.0, providing an embeddable, high-performance real-time pub/sub engine.

§Core Concepts

  • Broker — the message routing core responsible for publishing, subscribing, fan-out delivery, and replay. Ships with InMemoryBroker (in-process, all storage in memory).
  • Frame / Message — a Frame is the wire-level transport unit (JSON or CBOR encoded); a Message is the business-semantic layer carried inside a frame (commands, events, datagrams, snapshots, etc.).
  • Session — each WebSocket connection maps to a Session that manages authentication state, offset tracking, and heartbeat.
  • Transport — transport-layer abstraction with built-in adapters for axum, actix-web, warp, ntex, plus a standalone WebSocket listener.
  • Topic Profile — each topic can carry its own retention policy, ordering policy, subscriber/publisher limits, snapshot toggle, etc.

§Quick Start

use rifts::RiftServer;
use std::sync::Arc;
use tokio::sync::Notify;

let shutdown = Arc::new(Notify::new());
let server = RiftServer::builder()
    .websocket_transport()
    .build()?;
server.run("127.0.0.1:9000".parse().unwrap(), shutdown).await?;

§Module Overview (spec §30)

ModuleResponsibility
ackMessage acknowledgement (ack / nack) semantics and tracking
brokerMessage routing core — publish, subscribe, fan-out, dedupe
codecSerialization codecs (JSON / CBOR)
configServer configuration (payload limits, heartbeat policy, etc.)
connectionConnection-level processing — frame parsing, dispatch, backpressure
errorGlobal error type hierarchy
flowFlow control — backpressure, rate limiting
frameProtocol frame structure and codec helpers
messageMessage semantic layer (Command / Event / Datagram / Stream / Snapshot)
metricsProcess-local metric counters (exportable to Prometheus)
protocolProtocol constants — handshake, heartbeat, error codes, versioning, close codes
sessionSession management — authentication, offset tracking, resume
storagePersistent storage engine — append log, offset index, dedupe, snapshot
topicTopic profile — retention policy, ordering policy, storage binding
transportTransport-layer abstraction and framework adapters

Re-exports§

pub use broker::Broker;
pub use broker::InMemoryBroker;
pub use broker::PublishOutcome;
pub use broker::SubscribeIntent;
pub use config::ServerConfig;
pub use error::BoxedStdError;
pub use error::ConfigError;
pub use error::Result;
pub use error::RiftError;
pub use frame::Codec;
pub use frame::Frame;
pub use frame::FrameFlags;
pub use frame::FrameType;
pub use frame::Priority;
pub use message::DeliveryMode;
pub use message::Message;
pub use message::MessageClass;
pub use message::SubscribeResult;
pub use metrics::Metrics;
pub use protocol::close::CloseCode;
pub use protocol::error_code::ErrorCode;
pub use protocol::hello::AuthMode;
pub use protocol::hello::Hello;
pub use protocol::hello::Ready;
pub use protocol::hello::ResumeResult;
pub use protocol::hello::SdkInfo;
pub use protocol::hello::Welcome;
pub use server::RiftServer;
pub use server::RiftServerBuilder;
pub use session::AllowAllAuth;
pub use session::AuthContext;
pub use session::AuthHints;
pub use session::AuthProvider;
pub use session::ClientId;
pub use session::OffsetTracker;
pub use session::Session;
pub use session::SessionId;
pub use session::SessionState;
pub use session::SessionStore;
pub use session::TokenAuth;
pub use topic::OrderingPolicy;
pub use topic::RetentionPolicy;
pub use topic::TopicProfile;
pub use topic::TopicStore;
pub use transport::frame_codec::DEFAULT_MAX_BINARY_PAYLOAD;
pub use transport::frame_codec::decode_binary_frame;
pub use transport::frame_codec::decode_text_frame;
pub use transport::frame_codec::encode_frame;
pub use transport::websocket::WebSocketTransport;
pub use transport::Transport;
pub use transport::TransportConnection;
pub use transport::TransportListener;

Modules§

ack
Message acknowledgement (ack / nack) semantics and tracking. Acknowledgement system (Rift spec section 12).
broker
Message routing core — Broker trait and implementations. The broker subsystem (spec section 22).
codec
Serialization codecs (JSON, CBOR).
config
Server configuration structures and defaults.
connection
Connection-level processing — frame parsing, command dispatch, backpressure. Per-connection state machine — drives the Rift/1 connection lifecycle (spec section 5).
error
Global error type hierarchy.
flow
Flow control strategies — backpressure, rate limiting. Flow control module — backpressure management (Rift spec section 18).
frame
Protocol frame (Frame) structure and codec helpers.
message
Message semantic layer — Command, Event, Datagram, Stream, Snapshot, etc.
metrics
Process-local metric counters.
protocol
Protocol constants — handshake, heartbeat, error codes, versioning, close codes.
server
Server entry point — RiftServer and its Builder. Rift/1 server entry point.
session
Session management — authentication, offset tracking, resume.
storage
Persistent storage engine.
topic
Topic profile — retention policy, ordering policy, storage. Topic layer (Rift spec section 9).
transport
Transport-layer abstraction and framework adapters. Transport abstraction layer.