Scaffold dd0c/route core proxy engine (handler, router, auth, config)
This commit is contained in:
32
products/01-llm-cost-router/src/data/mod.rs
Normal file
32
products/01-llm-cost-router/src/data/mod.rs
Normal 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>>;
|
||||
}
|
||||
Reference in New Issue
Block a user