From 378433fc75fb0c67f719322e0f61d0214cddb336 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Wed, 25 Mar 2020 19:46:05 -0400 Subject: [PATCH] limit: Forward tower_load::Load (#429) --- tower-limit/Cargo.toml | 1 + tower-limit/src/concurrency/service.rs | 10 ++++++++++ tower-limit/src/rate/service.rs | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/tower-limit/Cargo.toml b/tower-limit/Cargo.toml index 3fb9159..d19858b 100644 --- a/tower-limit/Cargo.toml +++ b/tower-limit/Cargo.toml @@ -25,6 +25,7 @@ edition = "2018" futures-core = { version = "0.3", default-features = false } tower-service = "0.3" tower-layer = "0.3" +tower-load = "0.3" tokio = { version = "0.2", features = ["time"] } pin-project = "0.4" diff --git a/tower-limit/src/concurrency/service.rs b/tower-limit/src/concurrency/service.rs index 66643dd..bac2695 100644 --- a/tower-limit/src/concurrency/service.rs +++ b/tower-limit/src/concurrency/service.rs @@ -86,6 +86,16 @@ where } } +impl tower_load::Load for ConcurrencyLimit +where + S: tower_load::Load, +{ + type Metric = S::Metric; + fn load(&self) -> Self::Metric { + self.inner.load() + } +} + impl Clone for ConcurrencyLimit where S: Clone, diff --git a/tower-limit/src/rate/service.rs b/tower-limit/src/rate/service.rs index ff82228..76d40b9 100644 --- a/tower-limit/src/rate/service.rs +++ b/tower-limit/src/rate/service.rs @@ -108,3 +108,13 @@ where } } } + +impl tower_load::Load for RateLimit +where + S: tower_load::Load, +{ + type Metric = S::Metric; + fn load(&self) -> Self::Metric { + self.inner.load() + } +}