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
//! Multi-tenant namespace isolation and quota enforcement for Chronix.
//!
//! Provides tenant namespace management, per-namespace resource quotas,
//! and usage tracking. Each namespace encapsulates its own measurements,
//! schemas, models, and storage, preventing cross-tenant interference.
//!
//! # Architecture
//!
//! ```text
//! ┌───────────────────────────────────────────────┐
//! │ HTTP Layer │
//! │ X-Namespace header or /api/v1/ns/{ns}/... │
//! └───────────────────┬───────────────────────────┘
//! │
//! ┌──────────▼──────────┐
//! │ QuotaEnforcer │
//! │ check_and_increment_write() │
//! │ check_measurement()│
//! └──────────┬──────────┘
//! │
//! ┌──────────▼──────────┐
//! │ NamespaceRegistry │
//! │ DashMap<ns, state> │
//! │ CRUD + usage │
//! └─────────────────────┘
//! ```
//!
//! # Quick Start
//!
//! ```no_run
//! use chronix_security::tenant::{NamespaceRegistry, QuotaEnforcer};
//! use chronix_core::{NamespaceId, NamespaceQuota};
//!
//! let registry = NamespaceRegistry::new();
//!
//! // Create a namespace with custom quotas
//! let id = NamespaceId::new("team-platform").unwrap();
//! let quota = NamespaceQuota {
//! max_series_count: 500_000,
//! max_ingestion_rate: 50_000,
//! max_storage_bytes: 50 * 1024 * 1024 * 1024,
//! max_measurements: 200,
//! max_request_rps: 0,
//! max_request_burst: 0,
//! };
//! registry.create_namespace(id, "Platform team", "admin", quota).unwrap();
//!
//! // Enforce quotas on writes (atomic check + increment)
//! let enforcer = QuotaEnforcer::new(®istry);
//! enforcer.check_and_increment_write("team-platform", 10, 1000).unwrap();
//! ```
pub use ;
pub use ;
pub use ;