1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Request admission control.
//!
//! `[admission_control]` was accepted, echoed back in the boot log as "Admission
//! controller enabled", and enforced nothing: the controller was built and inserted
//! into the request extension map, which stores a value and gates no request. Every
//! `try_acquire` / `acquire_timeout` caller in the workspace was a test, so an
//! operator who set `max_concurrent = 500` to protect the box got a server that
//! behaved exactly as if no limit were configured (#860).
use Arc;
use ;
use AdmissionController;
/// Reject a request when the server is already at its concurrency limit.
///
/// The permit is held for the whole downstream call and released when this function
/// returns, so the limit tracks requests actually in flight. Over the limit, the
/// caller gets `503` immediately — the documented behaviour — rather than queueing on
/// the database pool behind every other request.
pub async