1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3pub mod adapter;
10pub mod adapters;
11#[cfg(feature = "proxy-daemon")]
12pub mod daemon;
13pub mod error;
14pub mod server;
15
16use std::net::SocketAddr;
17use std::sync::Arc;
18use std::time::Duration;
19
20use gaze::Pipeline;
21
22pub use adapter::{PiiSurface, ProviderAdapter, SseEvent};
23pub use error::ProxyError;
24pub use server::{serve, HealthSnapshot};
25
26#[derive(Clone)]
27#[non_exhaustive]
28pub struct ProxyConfig {
29 pub bind: SocketAddr,
30 pub adapters: Vec<Arc<dyn ProviderAdapter>>,
31 pub session_ttl: Duration,
32 pub body_limit_bytes: u64,
33}
34
35impl ProxyConfig {
36 pub fn new(bind: SocketAddr, adapters: Vec<Arc<dyn ProviderAdapter>>) -> Self {
37 Self {
38 bind,
39 adapters,
40 session_ttl: Duration::from_secs(30 * 60),
41 body_limit_bytes: 2 * 1024 * 1024,
42 }
43 }
44}
45
46pub async fn serve_foreground(
47 config: ProxyConfig,
48 pipeline: Arc<Pipeline>,
49) -> Result<(), ProxyError> {
50 serve(config, pipeline).await
51}