Skip to main content

ergon_io/
lib.rs

1#![doc = include_str!("../README.md")]
2//!
3//! ## Modules
4//!
5//! - [`backend`]: [`Backend`] and [`Config`] ([`Config::parse`] takes
6//!   `backend[,key=value...]`).
7//! - [`ws_conn`]: [`WsConn`], [`WsDial`], [`WsOptions`], [`WsHandler`];
8//!   [`ws`] is the frame codec.
9//! - [`reconnect`]: [`Reconnect`] and its backoff policy, [`Retry`].
10//! - [`http`]: [`HttpConn`], [`HttpDial`], [`HttpHandler`]. On Linux,
11//!   `client` pools connections as `HttpClient`.
12//! - [`tls`]: the TLS 1.3 client configuration ([`tls::client_config`]).
13//! - [`auth`]: request signing ([`Signer`]).
14//! - [`endpoint`]: [`Handler`] (`on_open`, `on_closed`), [`ConnId`], and
15//!   what a `Driver` takes ([`Endpoint`], [`Dial`]).
16//! - [`checks`] and [`route`]: the host, NIC and quick-ACK route checks,
17//!   built on ergon-tune.
18//! - [`placement`]: where the helper threads run (the connect helper, the
19//!   warning thread, `SQPOLL`), inside the process's cpuset.
20//! - [`limit`]: the send budget for venue rate limits ([`Budget`]).
21//! - [`outcome`]: what became of a request ([`Sent`], [`Verdict`]) and
22//!   `Retry-After` parsing.
23//! - [`net`] ([`Target`]), [`dns`], [`any`] ([`AnyConn`]:
24//!   WebSocket and HTTP on one driver), [`clock`], [`error`].
25//!
26//! `Driver`, `HttpClient`, `sys` and `warnings` are Linux-only, so they are
27//! named here without links.
28
29pub mod any;
30pub mod auth;
31pub mod backend;
32pub mod checks;
33pub mod clock;
34pub mod dns;
35pub mod endpoint;
36pub mod error;
37pub mod http;
38pub mod limit;
39pub mod net;
40pub mod outcome;
41pub mod placement;
42pub mod reconnect;
43pub mod route;
44mod stream;
45pub mod tls;
46pub mod ws;
47pub mod ws_conn;
48
49#[cfg(target_os = "linux")]
50pub mod client;
51#[cfg(all(target_os = "linux", feature = "curl"))]
52mod curl_client;
53#[cfg(target_os = "linux")]
54mod driver;
55#[cfg(target_os = "linux")]
56pub mod sys;
57#[cfg(target_os = "linux")]
58mod warn;
59
60/// ergon-io's warning thread (see [`checks`]): waiting for it to catch up.
61#[cfg(target_os = "linux")]
62pub mod warnings {
63    pub use crate::warn::flush;
64    /// Hidden test levers: capture and reset the lines the thread wrote
65    /// (`io/tests/driver_checks.rs`).
66    #[doc(hidden)]
67    pub use crate::warn::{forget_seen, keep_lines, take_lines};
68}
69
70pub use any::{AnyConn, AnyDial};
71pub use auth::{SignatureKind, Signer};
72pub use backend::{Backend, Config};
73#[cfg(target_os = "linux")]
74pub use client::{ClientHandler, CurlDrive, HttpClient, HttpClientConfig, HttpImpl};
75#[cfg(target_os = "linux")]
76pub use driver::Driver;
77pub use endpoint::{ConnId, ConnMut, Dial, DriverStats, Endpoint, Handler, Receive};
78pub use error::{Error, Result};
79pub use http::{HttpConn, HttpDial, HttpHandler, HttpOptions, HttpStats, Response};
80pub use limit::{
81    BucketId, BucketSpec, BucketStats, Budget, Charge, Class, Limited, Resend, Ticket, Why,
82};
83pub use net::Target;
84pub use outcome::{Now, Sent, Verdict};
85pub use reconnect::{Reconnect, Retry};
86pub use ws_conn::{WsConn, WsDial, WsHandler, WsOptions, WsStats};
87
88/// Receive metadata for one read.
89#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
90pub struct RxMeta {
91    /// Kernel software receive timestamp (`CLOCK_REALTIME` ns), 0 if absent.
92    pub rx_sw_ns: i64,
93    /// NIC hardware timestamp (raw PHC ns), 0 if absent.
94    pub rx_hw_ns: i64,
95    /// Sequence number of this read within its driver.
96    pub read_seq: u64,
97}