Expand description
In-memory usage counter store.
Counters are keyed by (tenant_id, period_yyyy_mm, entity_type) and stored
as lock-free AtomicU64 values inside a DashMap.
§Memory growth
This is a v1, unbounded store: entries are never evicted. Growth is
proportional to the product of #tenants × #periods × #entity_types.
For a deployment with 100 tenants, 12 months retention, and 50 entity types
that is at most 60 000 entries — approximately 5 MB. Eviction policies and
persistent storage are out of scope for v1.
§Restarts
Counters are in-memory only; they reset to zero on process restart.
The aggregator is wired into AppState and exposed via GET /api/v1/admin/usage.
Structs§
- Noop
Backend - No-op backend — counters are in-memory only, lost on restart.
- Postgres
Backend - PostgreSQL-backed usage persistence.
- Usage
Aggregator - Thread-safe, in-memory usage counter store with optional persistence backend.
- Usage
Summary - Per-period mutation counts for a single tenant.
Traits§
- Usage
Backend - Persistence backend for usage counters.
Functions§
- global_
aggregator - Return a reference to the process-wide
UsageAggregator. - validate_
period - Validate a usage period string in
"YYYY-MM"format.