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;
27
28#[cfg(feature = "dpdk")]
29pub mod dpdk_response;
30#[cfg(feature = "dpdk")]
31pub mod dpdk_transport;
32
33/// Control-plane event the accept loop, reader, and response stage
34/// exchange. Transport-agnostic — the payload is a socket fd + writer,
35/// not an app event — so both build modes refer to the same type.
36pub enum ControlEvent {
37 Connected {
38 connection_id: u64,
39 fd: std::os::unix::io::RawFd,
40 writer: melin_wire_protocol::blocking::BlockingFrameWriter<Box<dyn std::io::Write + Send>>,
41 },
42 Disconnected {
43 connection_id: u64,
44 },
45 /// Reader → response: the input pipeline was full when this
46 /// connection's frame arrived; deliver a `ServerBusy` notice through
47 /// the normal egress path. Routed through the response stage so
48 /// exactly one thread ever writes a client socket — a reader-side
49 /// send could land between the two halves of a partially-flushed
50 /// response frame and permanently desync the client's length-prefix
51 /// framing (2026-08 io_uring audit, review finding F3).
52 PipelineBusy {
53 connection_id: u64,
54 },
55}