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, ack-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//! [`StartupEvents`], `RequestDecoder`, `ResponseEncoder`, and event-
9//! publisher fn.
10//!
11//! The application-side wiring (the `Application` itself, its decoder
12//! and encoder, any event publisher) lives in the application's own
13//! crate — see the examples under `crates/examples/`.
14
15pub mod ack_policy;
16mod admin;
17mod batch_boundary;
18mod buf_ring;
19pub mod client_auth;
20mod client_frames;
21mod connection_limit;
22mod durability_gate;
23mod early_reply;
24mod halt;
25pub mod layout;
26mod policy_control;
27mod process;
28mod promotion;
29mod raft;
30mod raft_promotion;
31mod reader;
32pub mod replication;
33mod response;
34mod response_frame;
35pub mod server;
36mod startup;
37#[cfg(test)]
38mod test_roles;
39#[cfg(test)]
40mod tests;
41mod uring_teardown;
42
43pub use startup::StartupEvents;
44
45#[cfg(feature = "dpdk")]
46mod dpdk_response;
47#[cfg(feature = "dpdk")]
48mod dpdk_transport;
49
50// The two wire bounds an application's codecs have to fit: the widest
51// request body the readers hand a decoder, and the widest response body
52// the response stages give an encoder room for — both after the
53// protocol's framing, which the runtime reads and writes itself.
54// Re-exported here so an application can assert against them at compile
55// time, next to the bounds it declares (`AppEvent::MAX_ENCODED_SIZE` is
56// the journal's; these are the wire's).
57pub use client_frames::MAX_REQUEST_BODY;
58pub use response_frame::MAX_RESPONSE_BODY;
59
60/// Control-plane event the accept loop, reader, and response stage
61/// exchange. Transport-agnostic — the payload is a socket fd + writer,
62/// not an app event — so both build modes refer to the same type.
63pub(crate) enum ControlEvent {
64    Connected {
65        connection_id: u64,
66        fd: std::os::unix::io::RawFd,
67        writer: melin_wire_protocol::blocking::BlockingFrameWriter<Box<dyn std::io::Write + Send>>,
68    },
69    Disconnected {
70        connection_id: u64,
71    },
72}