nntp_proxy/lib.rs
1//! # NNTP Proxy Library
2//!
3//! A high-performance NNTP proxy server implementation with two operating modes:
4//! 1:1 mode (one backend per client) and per-command routing mode.
5//!
6//! ## Architecture
7//!
8//! The proxy is organized into several modules for clean separation of concerns:
9//!
10//! - **auth**: Authentication handling for both client and backend connections
11//! - **command**: NNTP command parsing and classification
12//! - **config**: Configuration loading and management
13//! - **pool**: Connection and buffer pooling for high performance
14//! - **protocol**: NNTP protocol constants and response parsing
15//! - **proxy**: Main proxy orchestration (`NntpProxy` struct)
16//! - **router**: Backend selection and load balancing
17//! - **types**: Core type definitions (`ClientId`, `RequestId`, `BackendId`)
18//!
19//! ## Design Philosophy
20//!
21//! This proxy operates in **stateless mode**, rejecting commands that require
22//! maintaining session state (like GROUP, NEXT, LAST). This design enables:
23//!
24//! - Simpler architecture with clear separation of concerns
25//! - Per-command routing mode where each command can use a different backend
26//! - Easy testing and maintenance of individual components
27//!
28//! ## Operating Modes
29//!
30//! - **1:1 mode**: Traditional mode where each client gets a dedicated backend connection
31//! - **Per-command routing mode**: Each command is routed to a backend (round-robin),
32//! but commands are still processed serially (NNTP is synchronous)
33
34// Module declarations
35pub mod args;
36pub mod auth;
37pub mod connection_error;
38pub mod formatting;
39pub mod metrics;
40pub mod network;
41pub mod protocol;
42mod proxy;
43pub mod stream;
44pub mod tui;
45
46// Test utilities (macros for reducing newtype test boilerplate)
47#[cfg(test)]
48#[macro_use]
49mod test_macros;
50
51// Public modules for integration tests
52pub mod cache;
53pub mod command;
54pub mod config;
55pub mod constants;
56pub mod health;
57pub mod pool;
58pub mod router;
59pub mod runtime;
60pub mod session;
61pub mod tls;
62pub mod types;
63
64// Public exports
65pub use args::{CacheArgs, CommonArgs};
66pub use config::{
67 Cache, Config, ConfigSource, RoutingMode, Server, create_default_config, has_server_env_vars,
68 load_config, load_config_from_env, load_config_with_fallback,
69};
70pub use network::SocketOptimizer;
71pub use proxy::{NntpProxy, NntpProxyBuilder, is_client_disconnect_error};
72pub use runtime::{RuntimeConfig, shutdown_signal};