Skip to content

Commit

Permalink
feat(layer): add throttle layer (#2444)
Browse files Browse the repository at this point in the history
* chore(core): add throttle layer module

* feat(core): add throttle layer

* feat(core): change throttle strategy based on PR review

* feat(core): refine docs and naming in ThrottleLayer
  • Loading branch information
morristai authored Jun 13, 2023
1 parent ccb81e3 commit 023fd08
Show file tree
Hide file tree
Showing 4 changed files with 380 additions and 1 deletion.
49 changes: 48 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ layers-all = [
"layers-prometheus",
"layers-tracing",
"layers-minitrace",
"layers-throttle",
]
# Enable layers chaos support
layers-chaos = ["dep:rand"]
Expand All @@ -90,6 +91,8 @@ layers-minitrace = ["dep:minitrace"]
layers-tracing = ["dep:tracing"]
# Enable layers oteltrace support.
layers-otel-trace = ["dep:opentelemetry"]
# Enable layers throttle support.
layers-throttle = ["dep:governor"]

services-azblob = [
"dep:sha2",
Expand Down Expand Up @@ -175,6 +178,7 @@ dashmap = { version = "5.4", optional = true }
dirs = { version = "5.0.1", optional = true }
flagset = "0.4"
futures = { version = "0.3", default-features = false, features = ["std"] }
governor = { version = "0.5", optional = true, features = ["std"] }
hdrs = { version = "0.2", optional = true, features = ["async_file"] }
http = "0.2.5"
hyper = "0.14"
Expand Down
6 changes: 6 additions & 0 deletions core/src/layers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,11 @@ pub use self::madsim::MadsimServer;

#[cfg(feature = "layers-otel-trace")]
mod oteltrace;

#[cfg(feature = "layers-throttle")]
mod throttle;
#[cfg(feature = "layers-throttle")]
pub use self::throttle::ThrottleLayer;

#[cfg(feature = "layers-otel-trace")]
pub use self::oteltrace::OtelTraceLayer;
Loading

0 comments on commit 023fd08

Please sign in to comment.