diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6771778..c15fed8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: - name: Check formatting run: cargo fmt --check - name: Check clippy - run: cargo clippy --verbose + run: cargo clippy -- -D warnings - name: Build run: cargo build --verbose - name: Run tests diff --git a/src/pipelines/mod.rs b/src/pipelines/mod.rs index 819afbb..626c2e4 100644 --- a/src/pipelines/mod.rs +++ b/src/pipelines/mod.rs @@ -1,4 +1 @@ pub mod pipeline; -pub mod plugin; -pub mod plugins; -pub mod services; diff --git a/src/pipelines/pipeline.rs b/src/pipelines/pipeline.rs index 0574e70..ab1430d 100644 --- a/src/pipelines/pipeline.rs +++ b/src/pipelines/pipeline.rs @@ -35,7 +35,7 @@ pub fn create_pipeline(pipeline: &Pipeline, model_registry: &ModelRegistry) -> R }; } - return router.with_state(Arc::new(model_registry.clone())); + router.with_state(Arc::new(model_registry.clone())) } pub async fn chat_completions( diff --git a/src/pipelines/plugin.rs b/src/pipelines/plugin.rs deleted file mode 100644 index efe4a07..0000000 --- a/src/pipelines/plugin.rs +++ /dev/null @@ -1,67 +0,0 @@ -use crate::config::models::PluginConfig; -use std::future::Future; -use std::pin::Pin; -use std::task::{Context, Poll}; -use tower::{Layer, Service}; - -pub trait Plugin { - fn name(&self) -> String; - fn enabled(&self) -> bool; - fn init(&mut self, config: &PluginConfig); - fn clone_box(&self) -> Box<dyn Plugin>; -} - -impl Clone for Box<dyn Plugin> { - fn clone(&self) -> Self { - self.clone_box() - } -} - -pub struct PluginMiddleware<S> { - inner: S, - plugin: Box<dyn Plugin>, -} - -impl<S, Request> Service<Request> for PluginMiddleware<S> -where - S: Service<Request>, - S::Future: Send + 'static, -{ - type Response = S::Response; - type Error = S::Error; - type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>; - - fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { - self.inner.poll_ready(cx) - } - - fn call(&mut self, request: Request) -> Self::Future { - if !self.plugin.enabled() { - let future = self.inner.call(request); - return Box::pin(async move { future.await }); - } - - let future = self.inner.call(request); - - Box::pin(async move { - let response = future.await?; - // Here you can add post-processing logic - Ok(response) - }) - } -} - -pub struct PluginLayer { - pub(crate) plugin: Box<dyn Plugin>, -} - -impl<S> Layer<S> for PluginLayer { - type Service = PluginMiddleware<S>; - - fn layer(&self, service: S) -> Self::Service { - PluginMiddleware { - inner: service, - plugin: self.plugin.clone(), - } - } -} diff --git a/src/pipelines/plugins/logging.rs b/src/pipelines/plugins/logging.rs deleted file mode 100644 index f90ab9f..0000000 --- a/src/pipelines/plugins/logging.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::config::models::PluginConfig; -use crate::pipelines::plugin::Plugin; - -pub struct LoggingPlugin; - -impl Plugin for LoggingPlugin { - fn name(&self) -> String { - "logging".to_string() - } - - fn enabled(&self) -> bool { - true - } - - fn init(&mut self, _config: &PluginConfig) -> () {} - - fn clone_box(&self) -> Box<dyn Plugin> { - Box::new(LoggingPlugin) - } -} diff --git a/src/pipelines/plugins/mod.rs b/src/pipelines/plugins/mod.rs deleted file mode 100644 index 8f89f06..0000000 --- a/src/pipelines/plugins/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod logging; -pub mod tracing; diff --git a/src/pipelines/plugins/tracing.rs b/src/pipelines/plugins/tracing.rs deleted file mode 100644 index b2b99e7..0000000 --- a/src/pipelines/plugins/tracing.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::config::models::PluginConfig; -use crate::pipelines::plugin::Plugin; - -pub struct TracingPlugin; - -impl Plugin for TracingPlugin { - fn name(&self) -> String { - "tracing".to_string() - } - - fn enabled(&self) -> bool { - true - } - - fn init(&mut self, _config: &PluginConfig) -> () {} - - fn clone_box(&self) -> Box<dyn Plugin> { - Box::new(TracingPlugin) - } -} diff --git a/src/pipelines/services/mod.rs b/src/pipelines/services/mod.rs deleted file mode 100644 index 8b13789..0000000 --- a/src/pipelines/services/mod.rs +++ /dev/null @@ -1 +0,0 @@ -