Scaffold dd0c/route core proxy engine (handler, router, auth, config)

This commit is contained in:
2026-03-01 02:23:27 +00:00
parent d038cd9c5c
commit cc003cbb1c
12 changed files with 872 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
use serde::{Deserialize, Serialize};
/// Telemetry event emitted by the proxy on every request.
/// Sent via mpsc channel to the worker for async persistence.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TelemetryEvent {
pub org_id: String,
pub original_model: String,
pub routed_model: String,
pub provider: String,
pub strategy: String,
pub latency_ms: u32,
pub status_code: u16,
pub is_streaming: bool,
pub prompt_tokens: u32,
pub completion_tokens: u32,
pub timestamp: chrono::DateTime<chrono::Utc>,
}
/// Abstraction over event queues (SQS for cloud, pgmq for self-hosted)
#[async_trait::async_trait]
pub trait EventQueue: Send + Sync {
async fn publish(&self, event: TelemetryEvent) -> anyhow::Result<()>;
async fn consume(&self, batch_size: usize) -> anyhow::Result<Vec<TelemetryEvent>>;
}
/// Abstraction over object storage (S3 for cloud, local FS for self-hosted)
#[async_trait::async_trait]
pub trait ObjectStore: Send + Sync {
async fn put(&self, key: &str, data: &[u8]) -> anyhow::Result<()>;
async fn get(&self, key: &str) -> anyhow::Result<Vec<u8>>;
}