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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Global runtime settings.
//!
//! The C reference exposes a single tunable, `msgs_per_sec`, accessed
//! through paired `msgs_per_sec()` / `set_msgs_per_sec()` functions.
//! The Rust port stores it in an [`AtomicU32`] so the getter and setter
//! are wait-free and lock-free.
use ;
/// Default value for [`msgs_per_sec`].
///
/// # Examples
///
/// ```
/// use dynomite::core::setting::DEFAULT_MSGS_PER_SEC;
/// assert_eq!(DEFAULT_MSGS_PER_SEC, 50_000);
/// ```
pub const DEFAULT_MSGS_PER_SEC: u32 = 50_000;
static MSGS_PER_SEC: AtomicU32 = new;
/// Return the current per-connection message-rate ceiling.
///
/// # Examples
///
/// ```
/// use dynomite::core::setting::{msgs_per_sec, DEFAULT_MSGS_PER_SEC};
/// assert!(msgs_per_sec() >= 1);
/// // The default may have been mutated by a previous test; check the constant
/// // independently to avoid cross-test ordering hazards.
/// assert_eq!(DEFAULT_MSGS_PER_SEC, 50_000);
/// ```
/// Update the per-connection message-rate ceiling.
///
/// # Examples
///
/// ```
/// use dynomite::core::setting::{msgs_per_sec, set_msgs_per_sec};
/// let prev = msgs_per_sec();
/// set_msgs_per_sec(7);
/// assert_eq!(msgs_per_sec(), 7);
/// set_msgs_per_sec(prev);
/// ```