diff --git a/Cargo.lock b/Cargo.lock index d7ffb72..b66266f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1201,16 +1201,6 @@ dependencies = [ "digest", ] -[[package]] -name = "http" -version = "0.1.0" -dependencies = [ - "future", - "hyper 1.3.1", - "metrics 0.1.0", - "tokio", -] - [[package]] name = "http" version = "0.2.12" @@ -3051,7 +3041,6 @@ dependencies = [ "future", "future_metrics", "geoip", - "http 0.1.0", "hyper 1.3.1", "metrics 0.1.0", "rate_limit", diff --git a/Cargo.toml b/Cargo.toml index 7a903d0..aa5e6ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,6 @@ full = [ "future", "geoblock", "geoip", - "http", "metrics", "rate_limit", ] @@ -31,9 +30,9 @@ collections = ["dep:collections"] future = ["dep:future"] geoblock = ["geoip/middleware"] geoip = ["dep:geoip"] -http = [] -metrics = ["dep:metrics", "future/metrics", "alloc/metrics", "http/metrics"] +metrics = ["dep:metrics", "future/metrics", "alloc/metrics"] future_metrics = ["dep:future_metrics"] +alloc_metrics = ["alloc/metrics"] profiler = ["alloc/profiler"] rate_limit = ["dep:rate_limit"] @@ -46,7 +45,6 @@ analytics = { path = "./crates/analytics", optional = true } collections = { path = "./crates/collections", optional = true } future = { path = "./crates/future", optional = true } geoip = { path = "./crates/geoip", optional = true } -http = { path = "./crates/http", optional = true } metrics = { path = "./crates/metrics", optional = true } future_metrics = { path = "./crates/future_metrics", optional = true } rate_limit = { path = "./crates/rate_limit", optional = true } diff --git a/crates/http/Cargo.toml b/crates/http/Cargo.toml deleted file mode 100644 index a785eb8..0000000 --- a/crates/http/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "http" -version = "0.1.0" -edition = "2021" - -[features] -default = [] -full = ["metrics"] -metrics = ["dep:metrics", "dep:future"] - -[dependencies] -future = { path = "../future", features = ["metrics"], optional = true } -metrics = { path = "../metrics", optional = true } -hyper = "1.2.0" -tokio = { version = "1", default-features = false, features = ["rt-multi-thread", "time", "macros"] } diff --git a/crates/http/src/executor.rs b/crates/http/src/executor.rs deleted file mode 100644 index ae79ccb..0000000 --- a/crates/http/src/executor.rs +++ /dev/null @@ -1,59 +0,0 @@ -use { - future::FutureExt, - metrics::TaskMetrics, - std::{future::Future, time::Duration}, -}; - -/// Global `hyper` service task executor that uses the `tokio` runtime and adds -/// metrics for the executed tasks. -#[derive(Default, Clone)] -pub struct ServiceTaskExecutor { - timeout: Option, - metrics_name: &'static str, -} - -impl ServiceTaskExecutor { - pub fn new() -> Self { - Default::default() - } - - /// Optional `task_name` metrics attribute. - pub fn name(self, metrics_name: Option<&'static str>) -> Self { - Self { - timeout: self.timeout, - metrics_name: metrics_name.unwrap_or(""), - } - } - - /// Apply a timeout to all service tasks to prevent them from becoming - /// zombies for various reasons. - /// - /// Default is no timeout. - pub fn timeout(self, timeout: Option) -> Self { - Self { - timeout, - metrics_name: self.metrics_name, - } - } -} - -impl hyper::rt::Executor for ServiceTaskExecutor -where - F: Future + Send + 'static, - F::Output: Send + 'static, -{ - fn execute(&self, fut: F) { - static METRICS: TaskMetrics = TaskMetrics::new("hyper_service_task"); - - let fut = fut.with_metrics(METRICS.with_name(self.metrics_name)); - let timeout = self.timeout; - - tokio::spawn(async move { - if let Some(timeout) = timeout { - let _ = fut.with_timeout(timeout).await; - } else { - fut.await; - } - }); - } -} diff --git a/crates/http/src/lib.rs b/crates/http/src/lib.rs deleted file mode 100644 index ea63635..0000000 --- a/crates/http/src/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[cfg(feature = "metrics")] -mod executor; - -#[cfg(feature = "metrics")] -pub use executor::*;