Skip to main content

Module ledger

Module ledger 

Source
Expand description

Pluggable cost ledger. The hot path enqueues onto a bounded channel drained by a background writer; on a full channel we drop + count, never block.

Modules§

connect
Resilient ledger wiring: connect configured sinks independently; on failure log and continue. When no sink connects, fall back to a no-op store so the gateway still starts and serves traffic.
event
talos-aligned published usage event (camelCase JSON). Decouples the wire format from the DB-shaped UsageEntry. Mirrors the conventions of talos-core/src/tool_events.rs (ToolEvent): rename_all = "camelCase", tenancy as namespace, a type discriminator, RFC3339 timestamp.
sqlite
SQLite ledger backend (feature ledger-sqlite).

Structs§

FanoutLedger
Records each entry to every configured sink, concurrently and independently. A sink failing never blocks the others; per-sink failures are logged and counted on synapse_ledger_errors_total{backend=<label>}. Always returns Ok — the ledger is fire-and-forget; the fan-out owns error reporting.
InMemoryLedger
In-memory store for tests.
LedgerHandle
Fire-and-forget handle. Cloneable; the hot path calls enqueue.
NoopLedger
Discards all usage events. Used when no ledger sink could be connected.
UsageEntry

Enums§

LedgerError

Traits§

LedgerStore