Skip to main content

melin_server_runtime/
lib.rs

1//! Application-agnostic LMAX-pipeline server runtime.
2//!
3//! Groups the application-agnostic parts of the Melin server: the
4//! accept loop, frame reader, durability-policy wiring, admin
5//! endpoint, replication, and the optional DPDK transport. Generic
6//! over `A: Application` — the binary supplies a concrete app via
7//! [`server::run`] (or [`server::run_dpdk`] under `feature = "dpdk"`) along with caller-supplied
8//! `AppFactory`, `RequestDecoder`, `ResponseEncoder`, and event-
9//! publisher fn.
10//!
11//! The trading-side wiring (`ServerApp`, `ExchangeRequestDecoder`,
12//! `ExchangeResponseEncoder`, market-data firehose) lives in the
13//! separate `melin-server` crate.
14
15pub mod admin;
16mod buf_ring;
17mod client_frames;
18pub mod durability_policy;
19pub mod process;
20pub mod promotion;
21mod raft;
22mod raft_promotion;
23pub mod reader;
24pub mod replication;
25pub mod response;
26pub mod server;
27mod uring_teardown;
28
29#[cfg(feature = "dpdk")]
30pub mod dpdk_response;
31#[cfg(feature = "dpdk")]
32pub mod dpdk_transport;
33
34/// Control-plane event the accept loop, reader, and response stage
35/// exchange. Transport-agnostic — the payload is a socket fd + writer,
36/// not an app event — so both build modes refer to the same type.
37pub enum ControlEvent {
38    Connected {
39        connection_id: u64,
40        fd: std::os::unix::io::RawFd,
41        writer: melin_wire_protocol::blocking::BlockingFrameWriter<Box<dyn std::io::Write + Send>>,
42    },
43    Disconnected {
44        connection_id: u64,
45    },
46    /// Reader → response: the input pipeline was full when this
47    /// connection's frame arrived; deliver a `ServerBusy` notice through
48    /// the normal egress path. Routed through the response stage so
49    /// exactly one thread ever writes a client socket — a reader-side
50    /// send could land between the two halves of a partially-flushed
51    /// response frame and permanently desync the client's length-prefix
52    /// framing (2026-08 io_uring audit, review finding F3).
53    PipelineBusy {
54        connection_id: u64,
55    },
56}