Compare commits

..

11 Commits

Author SHA1 Message Date
katelyn martin e8cc4ec47b
nit(app): remove frivolous code (#4094)
this commit removes a piece of code that has been commented out.

it additionally removes a variable binding that is not needed. `dst` is
not moved, so we do not need to bind the address of the destination
service to a variable, nor do we need to clone it.

Signed-off-by: katelyn martin <kate@buoyant.io>
2025-08-20 11:31:09 -04:00
dependabot[bot] b951a6c374
build(deps): bump tempfile from 3.20.0 to 3.21.0 (#4093)
Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.20.0 to 3.21.0.
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/commits)

---
updated-dependencies:
- dependency-name: tempfile
  dependency-version: 3.21.0
  dependency-type: indirect
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-20 10:13:45 -04:00
dependabot[bot] 7f6ac15f13
build(deps): bump cfg-if from 1.0.1 to 1.0.3 (#4092)
Bumps [cfg-if](https://github.com/rust-lang/cfg-if) from 1.0.1 to 1.0.3.
- [Release notes](https://github.com/rust-lang/cfg-if/releases)
- [Changelog](https://github.com/rust-lang/cfg-if/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cfg-if/compare/v1.0.1...v1.0.3)

---
updated-dependencies:
- dependency-name: cfg-if
  dependency-version: 1.0.3
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-20 10:13:04 -04:00
dependabot[bot] 75e9caaeae
build(deps): bump thiserror from 2.0.15 to 2.0.16 (#4091)
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 2.0.15 to 2.0.16.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/2.0.15...2.0.16)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-version: 2.0.16
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-20 10:12:43 -04:00
dependabot[bot] 02bbb3d617
build(deps): bump prettyplease from 0.2.36 to 0.2.37 (#4090)
Bumps [prettyplease](https://github.com/dtolnay/prettyplease) from 0.2.36 to 0.2.37.
- [Release notes](https://github.com/dtolnay/prettyplease/releases)
- [Commits](https://github.com/dtolnay/prettyplease/compare/0.2.36...0.2.37)

---
updated-dependencies:
- dependency-name: prettyplease
  dependency-version: 0.2.37
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-19 15:40:53 -04:00
dependabot[bot] 103c69ca75
build(deps): bump serde_json from 1.0.142 to 1.0.143 (#4088)
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.142 to 1.0.143.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.142...v1.0.143)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-version: 1.0.143
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-19 15:40:39 -04:00
dependabot[bot] 4663cc4eb6
build(deps): bump tinyvec from 1.9.0 to 1.10.0 (#4087)
Bumps [tinyvec](https://github.com/Lokathor/tinyvec) from 1.9.0 to 1.10.0.
- [Changelog](https://github.com/Lokathor/tinyvec/blob/main/CHANGELOG.md)
- [Commits](https://github.com/Lokathor/tinyvec/compare/v1.9.0...v1.10.0)

---
updated-dependencies:
- dependency-name: tinyvec
  dependency-version: 1.10.0
  dependency-type: indirect
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-19 15:40:31 -04:00
dependabot[bot] 03374b9543
build(deps): bump hyper from 1.6.0 to 1.7.0 (#4089)
Bumps [hyper](https://github.com/hyperium/hyper) from 1.6.0 to 1.7.0.
- [Release notes](https://github.com/hyperium/hyper/releases)
- [Changelog](https://github.com/hyperium/hyper/blob/master/CHANGELOG.md)
- [Commits](https://github.com/hyperium/hyper/compare/v1.6.0...v1.7.0)

---
updated-dependencies:
- dependency-name: hyper
  dependency-version: 1.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-19 15:40:03 -04:00
Scott Fleener 4c9ae74450 chore(metrics): Use `linkerd-rustls` for crypto provider metrics
Now that the `rustls` initialization/configuration has been decoupled from `linkerd-meshtls`, we can get the provider directly from there. This handles the uninitialized case better, which should be less of a problem now that we always directly initialize the provider in main.

Signed-off-by: Scott Fleener <scott@buoyant.io>
2025-08-19 14:06:32 -04:00
katelyn martin 94572d174d
refactor(http/classify): remove unused classification middleware (#4085)
`NewBroadcastClassification<C, X, N>` is not used.

`BroadcastClassification<C, S>` is only used by the `gate` submodule in
this crate.

this commit removes `NewBroadcastClassification`, since it is unused.
this commit demotes `channel` to an internal submodule, since it has no
external users.

the reëxport of `BroadcastClassification` is unused, though it is left
intact because it _is_ exposed by `NewClassifyGateSet`'s implementation
of `NewService<T>`.

Signed-off-by: katelyn martin <kate@buoyant.io>
2025-08-19 09:33:29 -04:00
katelyn martin 897c7e85bc
refactor(app/core): remove unused `gate` reëxport (#4084)
`linkerd_app_core::classify` reëxports symbols from
`linkerd_proxy_http::classify::gate`.

nothing makes use of this, and these symbols are already reëxported from
`linkerd_proxy_http::classify`. existing callsites in the outbound proxy
import this middleware directly, or though the reëxport in
`linkerd_proxy_http`.

this commit removes this `pub use` directive, since it does nothing.

Signed-off-by: katelyn martin <kate@buoyant.io>
2025-08-18 20:58:18 +00:00
7 changed files with 71 additions and 152 deletions

View File

@ -87,7 +87,7 @@ dependencies = [
"nom",
"num-traits",
"rusticata-macros",
"thiserror 2.0.15",
"thiserror 2.0.16",
"time",
]
@ -353,9 +353,9 @@ dependencies = [
[[package]]
name = "cfg-if"
version = "1.0.1"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
[[package]]
name = "clang-sys"
@ -910,7 +910,7 @@ dependencies = [
"once_cell",
"rand 0.9.2",
"ring",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tinyvec",
"tokio",
"tracing",
@ -933,7 +933,7 @@ dependencies = [
"rand 0.9.2",
"resolv-conf",
"smallvec",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tracing",
]
@ -996,13 +996,14 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
[[package]]
name = "hyper"
version = "1.6.0"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80"
checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e"
dependencies = [
"atomic-waker",
"bytes",
"futures-channel",
"futures-util",
"futures-core",
"h2",
"http",
"http-body",
@ -1010,6 +1011,7 @@ dependencies = [
"httpdate",
"itoa",
"pin-project-lite",
"pin-utils",
"smallvec",
"tokio",
"want",
@ -1352,7 +1354,7 @@ dependencies = [
"http",
"ipnet",
"linkerd-dns-name",
"thiserror 2.0.15",
"thiserror 2.0.16",
]
[[package]]
@ -1373,7 +1375,7 @@ dependencies = [
"linkerd-workers",
"rangemap",
"regex",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tokio-stream",
"tonic",
@ -1398,7 +1400,7 @@ dependencies = [
"pprof",
"serde",
"serde_json",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tower",
"tracing",
@ -1446,6 +1448,7 @@ dependencies = [
"linkerd-proxy-transport",
"linkerd-reconnect",
"linkerd-router",
"linkerd-rustls",
"linkerd-service-profiles",
"linkerd-stack",
"linkerd-stack-metrics",
@ -1458,9 +1461,8 @@ dependencies = [
"pin-project",
"prometheus-client",
"semver",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tokio-rustls",
"tokio-stream",
"tonic",
"tower",
@ -1480,7 +1482,7 @@ dependencies = [
"linkerd-proxy-client-policy",
"linkerd-proxy-server-policy",
"once_cell",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tokio-test",
"tonic",
@ -1518,7 +1520,7 @@ dependencies = [
"once_cell",
"parking_lot",
"rangemap",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tokio-test",
"tonic",
@ -1602,7 +1604,7 @@ dependencies = [
"parking_lot",
"pin-project",
"prometheus-client",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tokio-rustls",
"tokio-test",
@ -1628,7 +1630,7 @@ dependencies = [
"linkerd-proxy-client-policy",
"parking_lot",
"pin-project",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tokio-stream",
"tokio-test",
@ -1663,7 +1665,7 @@ dependencies = [
"linkerd-dns-name",
"linkerd-error",
"prometheus-client",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tracing",
]
@ -1672,7 +1674,7 @@ dependencies = [
name = "linkerd-dns-name"
version = "0.1.0"
dependencies = [
"thiserror 2.0.15",
"thiserror 2.0.16",
"untrusted",
]
@ -1697,7 +1699,7 @@ name = "linkerd-error"
version = "0.1.0"
dependencies = [
"futures",
"thiserror 2.0.15",
"thiserror 2.0.16",
]
[[package]]
@ -1718,7 +1720,7 @@ dependencies = [
"pin-project",
"quickcheck",
"rand 0.9.2",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
]
@ -1782,7 +1784,7 @@ dependencies = [
"linkerd-stack",
"linkerd-tracing",
"prometheus-client",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tokio-test",
"tracing",
@ -1845,7 +1847,7 @@ dependencies = [
"linkerd-stack",
"pin-project",
"prometheus-client",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
]
@ -1878,7 +1880,7 @@ dependencies = [
"linkerd-tracing",
"parking_lot",
"pin-project",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tower",
"tracing",
@ -1892,7 +1894,7 @@ dependencies = [
"linkerd2-proxy-api",
"rand 0.9.2",
"regex",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tracing",
"url",
]
@ -1908,7 +1910,7 @@ dependencies = [
"linkerd-stack",
"parking_lot",
"pin-project",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tracing",
]
@ -1930,7 +1932,7 @@ dependencies = [
"linkerd-io",
"linkerd-stack",
"pin-project",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tower",
"tracing",
@ -1942,7 +1944,7 @@ name = "linkerd-http-variant"
version = "0.1.0"
dependencies = [
"http",
"thiserror 2.0.15",
"thiserror 2.0.16",
]
[[package]]
@ -1953,7 +1955,7 @@ dependencies = [
"linkerd-error",
"linkerd-metrics",
"prometheus-client",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tracing",
"url",
]
@ -2003,7 +2005,7 @@ dependencies = [
"rcgen",
"rustls-pemfile",
"rustls-webpki",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tokio-rustls",
"tracing",
@ -2101,7 +2103,7 @@ dependencies = [
"linkerd-pool",
"linkerd-stack",
"parking_lot",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tower-test",
"tracing",
@ -2212,7 +2214,7 @@ dependencies = [
"linkerd2-proxy-api",
"once_cell",
"prost-types 0.13.5",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tonic",
]
@ -2271,7 +2273,7 @@ dependencies = [
"linkerd-stack",
"linkerd-tracing",
"pin-project",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tokio-test",
"tower",
@ -2289,7 +2291,7 @@ dependencies = [
"linkerd-identity",
"linkerd-stack",
"linkerd2-proxy-api",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tonic",
"tracing",
@ -2303,7 +2305,7 @@ dependencies = [
"linkerd-error",
"linkerd-proxy-core",
"pin-project",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tower",
"tracing",
]
@ -2321,7 +2323,7 @@ dependencies = [
"maplit",
"prost-types 0.13.5",
"quickcheck",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
]
@ -2338,7 +2340,7 @@ dependencies = [
"rcgen",
"simple_asn1",
"spiffe-proto",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tonic",
"tower",
@ -2369,7 +2371,7 @@ dependencies = [
"pin-project",
"prost-types 0.13.5",
"quickcheck",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tonic",
"tower",
@ -2399,7 +2401,7 @@ dependencies = [
"linkerd-io",
"linkerd-stack",
"socket2 0.6.0",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tokio-stream",
"tracing",
@ -2470,7 +2472,7 @@ dependencies = [
"prost-types 0.13.5",
"quickcheck",
"regex",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tokio-stream",
"tonic",
@ -2495,7 +2497,7 @@ dependencies = [
"linkerd-tracing",
"parking_lot",
"pin-project",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tokio-test",
"tokio-util",
@ -2539,7 +2541,7 @@ dependencies = [
"linkerd-stack",
"linkerd-tracing",
"pin-project",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tokio",
"tracing",
"untrusted",
@ -2552,7 +2554,7 @@ dependencies = [
"linkerd-dns",
"linkerd-tls",
"linkerd2-proxy-api",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tracing",
]
@ -2684,7 +2686,7 @@ dependencies = [
"prost 0.13.5",
"prost-types 0.13.5",
"quickcheck",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tonic",
]
@ -2957,7 +2959,7 @@ dependencies = [
"futures-sink",
"js-sys",
"pin-project-lite",
"thiserror 2.0.15",
"thiserror 2.0.16",
"tracing",
]
@ -2984,7 +2986,7 @@ dependencies = [
"opentelemetry",
"percent-encoding",
"rand 0.9.2",
"thiserror 2.0.15",
"thiserror 2.0.16",
]
[[package]]
@ -3126,7 +3128,7 @@ dependencies = [
"spin",
"symbolic-demangle",
"tempfile",
"thiserror 2.0.15",
"thiserror 2.0.16",
]
[[package]]
@ -3140,9 +3142,9 @@ dependencies = [
[[package]]
name = "prettyplease"
version = "0.2.36"
version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff24dfcda44452b9816fff4cd4227e1bb73ff5a2f1bc1105aa92fb8565ce44d2"
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
dependencies = [
"proc-macro2",
"syn",
@ -3630,9 +3632,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.142"
version = "1.0.143"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7"
checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a"
dependencies = [
"itoa",
"memchr",
@ -3683,7 +3685,7 @@ checksum = "297f631f50729c8c99b84667867963997ec0b50f32b2a7dbcab828ef0541e8bb"
dependencies = [
"num-bigint",
"num-traits",
"thiserror 2.0.15",
"thiserror 2.0.16",
"time",
]
@ -3817,9 +3819,9 @@ checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417"
[[package]]
name = "tempfile"
version = "3.20.0"
version = "3.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1"
checksum = "15b61f8f20e3a6f7e0649d825294eaf317edce30f82cf6026e7e4cb9222a7d1e"
dependencies = [
"fastrand",
"getrandom 0.3.1",
@ -3849,11 +3851,11 @@ dependencies = [
[[package]]
name = "thiserror"
version = "2.0.15"
version = "2.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80d76d3f064b981389ecb4b6b7f45a0bf9fdac1d5b9204c7bd6714fecc302850"
checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0"
dependencies = [
"thiserror-impl 2.0.15",
"thiserror-impl 2.0.16",
]
[[package]]
@ -3869,9 +3871,9 @@ dependencies = [
[[package]]
name = "thiserror-impl"
version = "2.0.15"
version = "2.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d29feb33e986b6ea906bd9c3559a856983f92371b3eaa5e83782a351623de0"
checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960"
dependencies = [
"proc-macro2",
"quote",
@ -3950,9 +3952,9 @@ dependencies = [
[[package]]
name = "tinyvec"
version = "1.9.0"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71"
checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa"
dependencies = [
"tinyvec_macros",
]
@ -4702,7 +4704,7 @@ dependencies = [
"nom",
"oid-registry",
"rusticata-macros",
"thiserror 2.0.15",
"thiserror 2.0.16",
"time",
]

View File

@ -22,7 +22,6 @@ ipnet = "2.11"
prometheus-client = { workspace = true }
thiserror = "2"
tokio = { version = "1", features = ["macros", "sync", "parking_lot"] }
tokio-rustls = { workspace = true }
tokio-stream = { version = "0.1", features = ["time"] }
tonic = { workspace = true, default-features = false, features = ["prost"] }
tracing = { workspace = true }
@ -57,6 +56,7 @@ linkerd-proxy-tcp = { path = "../../proxy/tcp" }
linkerd-proxy-transport = { path = "../../proxy/transport" }
linkerd-reconnect = { path = "../../reconnect" }
linkerd-router = { path = "../../router" }
linkerd-rustls = { path = "../../rustls" }
linkerd-service-profiles = { path = "../../service-profiles" }
linkerd-stack = { path = "../../stack" }
linkerd-stack-metrics = { path = "../../stack/metrics" }

View File

@ -1,5 +1,4 @@
use crate::profiles;
pub use classify::gate;
use linkerd_error::Error;
use linkerd_proxy_client_policy as client_policy;
use linkerd_proxy_http::{classify, HasH2Reason, ResponseTimeoutError};

View File

@ -4,7 +4,6 @@ use std::{
fmt::{Error, Write},
sync::{Arc, OnceLock},
};
use tracing::error;
static TLS_INFO: OnceLock<Arc<TlsInfo>> = OnceLock::new();
@ -45,14 +44,9 @@ pub fn metric() -> prom::Family<TlsInfo, prom::ConstGauge> {
prom::ConstGauge::new(1)
});
let Some(provider) = tokio_rustls::rustls::crypto::CryptoProvider::get_default() else {
// If the crypto provider hasn't been initialized, we return the metrics family with an
// empty set of metrics.
error!("Initializing TLS info metric before crypto provider initialized, this is a bug!");
return fam;
};
let tls_info = TLS_INFO.get_or_init(|| {
let provider = linkerd_rustls::get_default_provider();
let tls_suites = provider
.cipher_suites
.iter()

View File

@ -252,9 +252,6 @@ impl Config {
export_hostname_labels,
);
let dst_addr = dst.addr.clone();
// registry.sub_registry_with_prefix("gateway"),
let gateway = gateway::Gateway::new(gateway, inbound.clone(), outbound.clone()).stack(
dst.resolve.clone(),
dst.profiles.clone(),
@ -332,7 +329,7 @@ impl Config {
Ok(App {
admin,
dst: dst_addr,
dst: dst.addr,
drain: drain_tx,
identity,
inbound_addr,

View File

@ -2,7 +2,7 @@ use super::{ClassifyEos, ClassifyResponse};
use futures::{prelude::*, ready};
use http_body::Frame;
use linkerd_error::Error;
use linkerd_stack::{layer, ExtractParam, NewService, Service};
use linkerd_stack::Service;
use pin_project::{pin_project, pinned_drop};
use std::{
fmt::Debug,
@ -12,18 +12,6 @@ use std::{
};
use tokio::sync::mpsc;
/// Constructs new [`BroadcastClassification`] services.
///
/// `X` is an [`ExtractParam`] implementation that extracts a [`Tx`] from each
/// target. The [`Tx`] is used to broadcast the classification of each response
/// from the constructed [`BroadcastClassification`] service.
#[derive(Debug)]
pub struct NewBroadcastClassification<C, X, N> {
inner: N,
extract: X,
_marker: PhantomData<fn() -> C>,
}
/// A HTTP `Service` that applies a [`ClassifyResponse`] to each response, and
/// broadcasts the classification over a [`mpsc`] channel.
#[derive(Debug)]
@ -33,14 +21,6 @@ pub struct BroadcastClassification<C: ClassifyResponse, S> {
_marker: PhantomData<fn() -> C>,
}
/// A handle to a [`mpsc`] channel over which response classifications are
/// broadcasted.
///
/// This is extracted from a target value by [`NewBroadcastClassification`] when
/// constructing a [`BroadcastClassification`] service.
#[derive(Clone, Debug)]
pub struct Tx<C>(pub mpsc::Sender<C>);
#[pin_project]
pub struct ResponseFuture<C: ClassifyResponse, B, F> {
#[pin]
@ -62,59 +42,6 @@ struct State<C, T> {
tx: mpsc::Sender<T>,
}
// === impl NewBroadcastClassification ===
impl<C, X: Clone, N> NewBroadcastClassification<C, X, N> {
pub fn new(extract: X, inner: N) -> Self {
Self {
inner,
extract,
_marker: PhantomData,
}
}
/// Returns a [`layer::Layer`] that constructs `NewBroadcastClassification`
/// [`NewService`]s, using the provided [`ExtractParam`] implementation to
/// extract a classification [`Tx`] from the target.
pub fn layer_via(extract: X) -> impl layer::Layer<N, Service = Self> + Clone {
layer::mk(move |inner| Self::new(extract.clone(), inner))
}
}
impl<C, N> NewBroadcastClassification<C, (), N> {
/// Returns a [`layer::Layer`] that constructs `NewBroadcastClassification`
/// [`NewService`]s when the target type implements
/// [`linkerd_stack::Param`]`<`[`Tx`]`>`.
pub fn layer() -> impl layer::Layer<N, Service = Self> + Clone {
Self::layer_via(())
}
}
impl<T, C, X, N> NewService<T> for NewBroadcastClassification<C, X, N>
where
C: ClassifyResponse,
X: ExtractParam<Tx<C::Class>, T>,
N: NewService<T>,
{
type Service = BroadcastClassification<C, N::Service>;
fn new_service(&self, target: T) -> Self::Service {
let Tx(tx) = self.extract.extract_param(&target);
let inner = self.inner.new_service(target);
BroadcastClassification::new(tx, inner)
}
}
impl<C, X: Clone, N: Clone> Clone for NewBroadcastClassification<C, X, N> {
fn clone(&self) -> Self {
Self {
inner: self.inner.clone(),
extract: self.extract.clone(),
_marker: PhantomData,
}
}
}
// === impl BroadcastClassification ===
impl<C: ClassifyResponse, S> BroadcastClassification<C, S> {

View File

@ -4,12 +4,12 @@
use linkerd_error::Error;
pub use self::{
channel::{BroadcastClassification, NewBroadcastClassification, Tx},
channel::BroadcastClassification,
gate::{NewClassifyGate, NewClassifyGateSet},
insert::{InsertClassifyResponse, NewInsertClassifyResponse},
};
pub mod channel;
mod channel;
pub mod gate;
mod insert;