How to trigger ConcurrencyLimitLayer
?
#887
Answered
by
davidpdrsn
goldwind-ting
asked this question in
Q&A
-
use axum::{
routing::get,
response::IntoResponse,
Router,
};
use tracing::info;
use tower::limit::ConcurrencyLimitLayer;
use tower_http::trace::TraceLayer;
async fn handle() -> impl IntoResponse {
"OK"
}
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let middleware = tower::ServiceBuilder::new()
.layer(TraceLayer::new_for_http())
.layer(ConcurrencyLimitLayer::new(1));
let app = Router::new()
.route("/api/v1", get(handle))
.layer(middleware);
let addr = &"[::]:23818".parse().unwrap();
info!("listening on {}", addr);
axum::Server::bind(addr)
.serve(app.into_make_service())
.await.unwrap();
} I executed |
Beta Was this translation helpful? Give feedback.
Answered by
davidpdrsn
Mar 25, 2022
Replies: 1 comment 1 reply
-
Why would you expect a panic? |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
davidpdrsn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why would you expect a panic?
ConcurrencyLimitLayer
doesn't panic when it's at capacity but returnsPending
fromService::poll_ready
.