#![warn(missing_docs)]
#![warn(clippy::all)]
#![allow(clippy::module_inception)]
mod auth;
pub mod config;
pub mod core;
mod monitoring;
pub mod sdk; pub mod server;
pub mod storage;
pub mod utils;
pub use config::Config;
pub use utils::error::{GatewayError, Result};
use tracing::info;
pub struct Gateway {
config: Config,
server: server::HttpServer,
}
impl Gateway {
pub async fn new(config: Config) -> Result<Self> {
info!("Creating new gateway instance");
let server = server::HttpServer::new(&config).await?;
Ok(Self { config, server })
}
pub async fn run(self) -> Result<()> {
info!("Starting LiteLLM Gateway");
info!("Configuration: {:#?}", self.config);
self.server.start().await?;
Ok(())
}
}
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const NAME: &str = env!("CARGO_PKG_NAME");
pub const DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION");
#[derive(Debug, Clone)]
pub struct BuildInfo {
pub version: &'static str,
pub build_time: &'static str,
pub git_hash: &'static str,
pub rust_version: &'static str,
}
impl Default for BuildInfo {
fn default() -> Self {
Self {
version: VERSION,
build_time: "unknown",
git_hash: "unknown",
rust_version: "unknown",
}
}
}
pub fn build_info() -> BuildInfo {
BuildInfo::default()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_build_info() {
let info = build_info();
assert!(!info.version.is_empty());
assert_eq!(info.version, VERSION);
}
#[test]
fn test_constants() {
assert_eq!(VERSION, env!("CARGO_PKG_VERSION"));
assert_eq!(NAME, env!("CARGO_PKG_NAME"));
assert_eq!(DESCRIPTION, env!("CARGO_PKG_DESCRIPTION"));
}
}