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
//! Global resource quotas.
//!
//! Memory and disk are node-wide resources, so their limits are configured once
//! for the whole cluster rather than per collection. [`QuotaManager`] owns that
//! configuration: it is seeded from the storage settings (and thus from config
//! files and environment variables), overridden by a quota file persisted at the
//! root of the storage directory, and updated cluster-wide through consensus.
//! `storage` re-exports this module and drives all of that.
//!
//! It is also the single place that measures those resources, for its own limit
//! checks and for anything else that needs to know how full a disk is — the
//! optimizer sizing up a merge, the WAL checking it has room to write. Nothing
//! else calls `statvfs` or reads process memory.
//!
//! The quota is the only limit it enforces. Code with a limit of its own — a
//! collection's deprecated `max_resident_memory_percent` — enforces that itself
//! against a measurement taken from here, so no per-collection setting can lift
//! a cluster-wide limit by going through this.
use ;
pub use ;
pub use ;
pub use ;
pub use ;
static GLOBAL: = new;
/// Install the node's quota manager, once at startup before anything measures a
/// resource. `storage` does it while building the table of contents.
///
/// A second call is a startup-order bug — the quota it configures would silently
/// not be the one enforced — so it is loud rather than ignored.
/// The node's quota manager. Falls back to one that enforces nothing for
/// binaries with no quota config to install — edge, and tests — whose
/// measurements still work, which is all a non-enforcing caller needs.