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
39
40
41
42
43
44
45
46
47
use Duration;
/// Sustained request rate, in requests per second.
pub const DEFAULT_RATE_PER_SEC: f64 = 2.0;
/// Burst capacity: how many requests may fire back-to-back before the
/// sustained rate kicks in. SpaceTraders allows a short burst on top of the
/// strict ~2 req/s, so the bucket alone keeps us within budget.
pub const DEFAULT_BURST: f64 = 10.0;
/// Anti-starvation: a waiter's effective priority is bumped up one level for
/// every interval it has spent queued. A `Low` request thus overtakes freshly
/// arriving `Normal` work after ~2 intervals and `Critical` after ~3, so a
/// steady stream of higher-priority requests can never block it forever.
pub const DEFAULT_AGING_INTERVAL: Duration = from_secs;
/// Priority of a queued request. Higher-priority requests receive the next
/// available permit before lower-priority ones; within the same priority the
/// scheduler is first-in, first-out.
///
/// ```
/// use spacetraders_client::RequestPriority;
///
/// assert!(RequestPriority::Critical > RequestPriority::Normal);
/// assert!(RequestPriority::Normal > RequestPriority::Low);
/// ```