Skip to main content

autumn_plugin_pingora/
lib.rs

1//! A [Pingora](https://github.com/cloudflare/pingora) reverse proxy for
2//! [Autumn](https://autumn-web.app).
3//!
4//! ```rust,ignore
5//! use autumn_plugin_pingora::{PingoraPlugin, Route};
6//!
7//! #[autumn_web::main]
8//! async fn main() {
9//!     autumn_web::app()
10//!         .routes(routes![index])
11//!         .plugin(PingoraPlugin::new().route(
12//!             Route::new("billing").path_prefix("/billing").upstream("10.0.0.7:8080"),
13//!         ))
14//!         .run()
15//!         .await;
16//! }
17//! ```
18//!
19//! The proxy has its own listener. The default is `127.0.0.1:8080` in
20//! `dev` and `test`, and `0.0.0.0:8080` in other profiles. The proxy sends
21//! matched requests to the route's upstream pool. It sends all other
22//! requests to the Autumn app. It adds:
23//!
24//! - round-robin or consistent-hash load balancing,
25//! - TCP health checks and connect retries,
26//! - `X-Forwarded-*` headers,
27//! - body and connection limits,
28//! - a `pingora` indicator in `/actuator/health`,
29//! - `pingora_proxy_*` metrics in `/actuator/prometheus`,
30//! - graceful drain on Autumn's shutdown signal.
31//!
32//! See [`PingoraConfig`] for the `[pingora]` section of `autumn.toml`.
33
34#![forbid(unsafe_code)]
35
36mod config;
37mod error;
38mod forwarded;
39mod health;
40mod lifecycle;
41mod metrics;
42mod plugin;
43mod proxy;
44mod router;
45mod server;
46mod upstream;
47
48pub use config::{
49    ConfigError, DEFAULT_PORT, DEFAULT_SECTION, Fallback, MAX_CONNECTIONS_LIMIT, PingoraConfig,
50    Resolved, Route, Selection,
51};
52pub use error::PingoraError;
53pub use lifecycle::{Lifecycle, LifecycleCell, LifecycleEvent};
54pub use plugin::{PLUGIN_NAME, PingoraPlugin};
55pub use server::{PingoraHandle, UpstreamHealth};