Sentinel is organized as a Cargo workspace with four core crates. This page explains each component’s responsibilities and how they interact.
Crate Structure
sentinel/
├── crates/
│ ├── proxy/ # Main proxy binary and library
│ ├── config/ # Configuration parsing and validation
│ ├── agent-protocol/ # Agent communication protocol
│ └── common/ # Shared types and utilities
└── agents/
└── echo/ # Reference agent implementation
Proxy Crate
Package: sentinel-proxy
Binary: sentinel
The main proxy implementation that ties everything together.
Key Modules
| Module | Purpose |
|---|---|
main.rs | CLI entry point, signal handling |
proxy/ | Core proxy logic, Pingora integration |
routing.rs | Route matching and compilation |
upstream/ | Upstream pool management, load balancing |
agents/ | Agent manager and coordination |
static_files/ | Static file serving |
health.rs | Active and passive health checking |
reload/ | Configuration hot reload |
logging.rs | Access, error, and audit logging |
Proxy Module
The SentinelProxy struct implements Pingora’s ProxyHttp trait:
Routing Module
Routes are compiled at startup for efficient matching:
Upstream Module
Manages backend server pools with multiple load balancing strategies:
Load Balancing Algorithms:
| Algorithm | Description | Use Case |
|---|---|---|
round_robin | Sequential rotation | General purpose |
least_connections | Fewest active connections | Variable latency backends |
ip_hash | Hash client IP | Session affinity |
consistent_hash | Consistent hashing | Cache distribution |
p2c | Power of Two Choices | Low latency selection |
adaptive | Adjusts based on response times | Mixed workloads |
Agent Module
Coordinates external agent communication:
Config Crate
Package: sentinel-config
Handles configuration parsing, validation, and hot reload.
Supported Formats
- KDL (primary) - Human-friendly document language
- TOML - Standard configuration format
- YAML - For Kubernetes integration
- JSON - For programmatic generation
Configuration Structure
Key Types
Validation
Configuration is validated at multiple levels:
- Schema validation - Structure and types
- Semantic validation - Cross-references (route → upstream)
- Custom validators - Business rules
Hot Reload
Configuration changes are applied atomically:
Agent Protocol Crate
Package: sentinel-agent-protocol
Defines the contract between Sentinel and external agents.
Transport Options
| Transport | Format | Use Case |
|---|---|---|
| Unix Socket | JSON | Default, same-host agents |
| gRPC | Protobuf | Cross-host, high-performance |
Protocol Types
Header Mutations
Agents can modify request and response headers:
Client and Server
// Proxy side - calls agents
// Agent side - receives calls
Common Crate
Package: sentinel-common
Shared types and utilities used across all crates.
Type-Safe IDs
// Strongly typed identifiers prevent mix-ups
;
;
;
;
;
Error Types
pub type SentinelResult<T> = ;
Circuit Breaker
Limits
Observability
Component Interactions
┌─────────────────────────────────────────────────────────────────┐
│ sentinel-proxy │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────────────────┐│
│ │ Routing │ │Upstream │ │ Agents │ │ Static Files ││
│ └────┬────┘ └────┬────┘ └────┬────┘ └─────────────────────┘│
│ │ │ │ │
└───────┼────────────┼────────────┼───────────────────────────────┘
│ │ │
│ │ │
┌───────▼────────────▼────────────▼───────────────────────────────┐
│ sentinel-config │
│ ┌─────────────┐ ┌──────────────┐ ┌────────────────────────┐ │
│ │ Parsing │ │ Validation │ │ Hot Reload │ │
│ └─────────────┘ └──────────────┘ └────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
│
│
┌───────▼─────────────────────────────────────────────────────────┐
│ sentinel-agent-protocol │
│ ┌─────────────┐ ┌──────────────┐ ┌────────────────────────┐ │
│ │ Client │ │ Types │ │ Server │ │
│ └─────────────┘ └──────────────┘ └────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
│
│
┌───────▼─────────────────────────────────────────────────────────┐
│ sentinel-common │
│ ┌─────────┐ ┌──────────┐ ┌─────────┐ ┌──────────────────┐ │
│ │ Types │ │ Errors │ │ Circuit │ │ Observability │ │
│ │ (IDs) │ │ │ │ Breaker │ │ │ │
│ └─────────┘ └──────────┘ └─────────┘ └──────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
Next Steps
- Architecture Overview - High-level design
- Request Flow - Detailed request lifecycle
- Routing System - How routes are matched