Skip to content

Commit 869fd2e

Browse files
authored
Merge pull request #302 from semiotic-ai/fix/grpc_limits
fix: add layer to set concurrent limits for gRPC
2 parents 6406f29 + d539df4 commit 869fd2e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

tap_aggregator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ tap_graph.workspace = true
3232
thegraph-core = { workspace = true, features = ["alloy-eip712"] }
3333
tokio.workspace = true
3434
tonic.workspace = true
35-
tower.workspace = true
35+
tower = { workspace = true, features = ["util", "steer", "limit"] }
3636
tracing-subscriber.workspace = true
3737

3838
[build-dependencies]

tap_aggregator/src/server.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,14 @@ pub async fn run_server(
378378

379379
let grpc_service = create_grpc_service(rpc_impl)?;
380380

381+
let grpc_router = Router::new()
382+
.layer(tower::limit::ConcurrencyLimitLayer::new(
383+
max_concurrent_connections as usize,
384+
))
385+
.merge(grpc_service.into_axum_router());
386+
381387
let service = tower::steer::Steer::new(
382-
[json_rpc_router, grpc_service.into_axum_router()],
388+
[json_rpc_router, grpc_router],
383389
|req: &hyper::Request<_>, _services: &[_]| {
384390
if req
385391
.headers()

0 commit comments

Comments
 (0)