Skip to content

Commit 0fa39ed

Browse files
authored
replace linkerd-concurrency-limit with Tower (#1107)
tower-rs/tower#574 added a `GlobalConcurrencyLimitLayer` which has the same behavior as our `linkerd-concurrency-limit` crate (sharing a single semaphore across all instances of a service). This was published in Tower 0.4.8, and now that we've updated to that version, we can remove our implementation in favor of upstream.
1 parent 634a5fd commit 0fa39ed

File tree

9 files changed

+8
-167
lines changed

9 files changed

+8
-167
lines changed

Cargo.lock

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,6 @@ dependencies = [
665665
"ipnet",
666666
"linkerd-addr",
667667
"linkerd-cache",
668-
"linkerd-concurrency-limit",
669668
"linkerd-conditional",
670669
"linkerd-detect",
671670
"linkerd-dns",
@@ -844,19 +843,6 @@ dependencies = [
844843
"tracing",
845844
]
846845

847-
[[package]]
848-
name = "linkerd-concurrency-limit"
849-
version = "0.1.0"
850-
dependencies = [
851-
"futures",
852-
"linkerd-stack",
853-
"pin-project",
854-
"tokio",
855-
"tokio-util",
856-
"tower",
857-
"tracing",
858-
]
859-
860846
[[package]]
861847
name = "linkerd-conditional"
862848
version = "0.1.0"

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ members = [
1515
"linkerd/app/test",
1616
"linkerd/app",
1717
"linkerd/cache",
18-
"linkerd/concurrency-limit",
1918
"linkerd/conditional",
2019
"linkerd/detect",
2120
"linkerd/transport-header",

linkerd/app/core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ futures = { version = "0.3", default-features = false }
2222
ipnet = "2.3"
2323
linkerd-addr = { path = "../../addr" }
2424
linkerd-cache = { path = "../../cache" }
25-
linkerd-concurrency-limit = { path = "../../concurrency-limit" }
2625
linkerd-conditional = { path = "../../conditional" }
2726
linkerd-dns = { path = "../../dns" }
2827
linkerd-detect = { path = "../../detect" }
@@ -78,6 +77,7 @@ features = [
7877
"spawn-ready",
7978
"timeout",
8079
"util",
80+
"limit",
8181
]
8282

8383
[target.'cfg(target_os = "linux")'.dependencies]

linkerd/app/core/src/svc.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
pub use crate::proxy::http;
44
use crate::{cache, Error};
5-
pub use linkerd_concurrency_limit::ConcurrencyLimit;
65
use linkerd_error::Recover;
76
use linkerd_exp_backoff::{ExponentialBackoff, ExponentialBackoffStream};
87
pub use linkerd_reconnect::NewReconnect;
@@ -21,7 +20,10 @@ use tower::{
2120
layer::util::{Identity, Stack as Pair},
2221
make::MakeService,
2322
};
24-
pub use tower::{layer::Layer, service_fn as mk, spawn_ready::SpawnReady, Service, ServiceExt};
23+
pub use tower::{
24+
layer::Layer, limit::GlobalConcurrencyLimitLayer as ConcurrencyLimitLayer, service_fn as mk,
25+
spawn_ready::SpawnReady, Service, ServiceExt,
26+
};
2527

2628
#[derive(Copy, Clone, Debug)]
2729
pub struct AlwaysReconnect(ExponentialBackoff);

linkerd/app/inbound/src/http/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<H> Inbound<H> {
7575
// to `NewRouter`) and the concurrency limit need not be
7676
// driven outside of the request path, so there's no need
7777
// for SpawnReady
78-
.push(svc::ConcurrencyLimit::layer(max_in_flight_requests))
78+
.push(svc::ConcurrencyLimitLayer::new(max_in_flight_requests))
7979
.push(svc::FailFast::layer("HTTP Server", dispatch_timeout))
8080
.push(rt.metrics.http_errors.clone())
8181
// Synthesizes responses for proxy errors.

linkerd/app/outbound/src/http/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<N> Outbound<N> {
4747
// background task to ensure it becomes ready without new
4848
// requests being processed.
4949
.push(svc::layer::mk(svc::SpawnReady::new))
50-
.push(svc::ConcurrencyLimit::layer(max_in_flight_requests))
50+
.push(svc::ConcurrencyLimitLayer::new(max_in_flight_requests))
5151
.push(svc::FailFast::layer("HTTP Server", dispatch_timeout))
5252
.push_spawn_buffer(buffer_capacity)
5353
.push(rt.metrics.http_errors.clone())

linkerd/app/outbound/src/ingress.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl Outbound<svc::BoxNewHttp<http::Endpoint>> {
206206
// The concurrency-limit can force the service into fail-fast, but it need not
207207
// be driven to readiness on a background task (i.e., by `SpawnReady`).
208208
// Otherwise, the inner service is always ready (because it's a router).
209-
.push(svc::ConcurrencyLimit::layer(max_in_flight_requests))
209+
.push(svc::ConcurrencyLimitLayer::new(max_in_flight_requests))
210210
.push(svc::FailFast::layer("Ingress server", dispatch_timeout))
211211
.push(rt.metrics.http_errors.clone())
212212
.push(errors::layer())

linkerd/concurrency-limit/Cargo.toml

Lines changed: 0 additions & 17 deletions
This file was deleted.

linkerd/concurrency-limit/src/lib.rs

Lines changed: 0 additions & 129 deletions
This file was deleted.

0 commit comments

Comments
 (0)