sentinel_proxy/
lib.rs

1//! Sentinel Proxy Library
2//!
3//! A security-first reverse proxy built on Pingora with sleepable ops at the edge.
4//!
5//! This library provides the core components for building a production-grade
6//! reverse proxy with:
7//!
8//! - **Routing**: Flexible path-based and header-based routing
9//! - **Upstream Management**: Load balancing, health checking, circuit breakers
10//! - **Static File Serving**: Compression, caching, range requests
11//! - **Validation**: JSON Schema validation for API requests/responses
12//! - **Error Handling**: Customizable error pages per service type
13//! - **Hot Reload**: Configuration changes without restarts
14//!
15//! # Example
16//!
17//! ```ignore
18//! use sentinel_proxy::{StaticFileServer, ErrorHandler, SchemaValidator};
19//! use sentinel_config::{StaticFileConfig, ServiceType};
20//!
21//! // Create a static file server
22//! let config = StaticFileConfig::default();
23//! let server = StaticFileServer::new(config);
24//!
25//! // Create an error handler for API responses
26//! let handler = ErrorHandler::new(ServiceType::Api, None);
27//! ```
28
29
30// ============================================================================
31// Module Declarations
32// ============================================================================
33
34pub mod agents;
35pub mod app;
36pub mod builtin_handlers;
37pub mod errors;
38pub mod health;
39pub mod http_helpers;
40pub mod logging;
41pub mod proxy;
42pub mod reload;
43pub mod routing;
44pub mod static_files;
45pub mod trace_id;
46pub mod upstream;
47pub mod validation;
48
49// ============================================================================
50// Public API Re-exports
51// ============================================================================
52
53// Error handling
54pub use errors::ErrorHandler;
55
56// Static file serving
57pub use static_files::{CacheStats, CachedFile, FileCache, StaticFileServer};
58
59// Request validation
60pub use validation::SchemaValidator;
61
62// Routing
63pub use routing::{RouteMatcher, RouteMatch, RequestInfo};
64
65// Upstream management
66pub use upstream::{
67    LoadBalancer, PoolStats, RequestContext, TargetSelection, UpstreamPool, UpstreamTarget,
68};
69
70// Health checking
71pub use health::{ActiveHealthChecker, PassiveHealthChecker, TargetHealthInfo};
72
73// Agents
74pub use agents::{AgentAction, AgentCallContext, AgentDecision, AgentManager};
75
76// Hot reload
77pub use reload::{ConfigManager, ReloadEvent, ReloadTrigger, SignalManager, SignalType};
78
79// Application state
80pub use app::AppState;
81
82// Proxy core
83pub use proxy::SentinelProxy;
84
85// Built-in handlers
86pub use builtin_handlers::{
87    execute_handler, BuiltinHandlerState, TargetHealthStatus, TargetStatus, UpstreamHealthSnapshot,
88    UpstreamStatus,
89};
90
91// HTTP helpers
92pub use http_helpers::{
93    extract_request_info, get_or_create_trace_id, write_error, write_json_error, write_response,
94    write_text_error,
95};
96
97// Trace ID generation (TinyFlake)
98pub use trace_id::{generate_for_format, generate_tinyflake, generate_uuid, TraceIdFormat, TINYFLAKE_LENGTH};
99
100// Logging
101pub use logging::{
102    AccessLogEntry, AccessLogFormat, AuditLogEntry, ErrorLogEntry, LogManager, SharedLogManager,
103};
104
105// Re-export common error types for convenience
106pub use sentinel_common::errors::{LimitType, SentinelError, SentinelResult};