Documentation
¶
Overview ¶
Package quotastore persists per-identity quotas in the hub's own state database (Task 20182).
It is the SQLite half of the split described in pkg/quota: that package owns the policy — precedence, admission, the atomic check-and-increment — and is stdlib-only, while this one owns the rows. The seam is quota.Store, and it is the same shape as oidcauth.SessionStore/sessionstore and secretbroker.Store/secretstore.
Nothing here is encrypted. A quota row holds a ceiling and a count, which is policy and telemetry rather than credential material; the identity strings it is keyed by are already in plaintext in the project registry and the session table. Sealing them would cost the ability to read the table during an incident and buy nothing an attacker with database access does not already have.
Index ¶
- type Store
- func (s *Store) AdjustCounter(identity string, res quota.Resource, bucket string, delta, limit float64, ...) (float64, bool, error)
- func (s *Store) DeleteOverride(identity string) (bool, error)
- func (s *Store) LoadCounters() ([]quota.CounterRow, error)
- func (s *Store) LoadOverrides() ([]quota.Override, error)
- func (s *Store) PruneCountersBefore(bucket string) error
- func (s *Store) PutCounter(c quota.CounterRow) error
- func (s *Store) PutOverride(o quota.Override) error
- func (s *Store) ReplaceGauges(rows []quota.CounterRow) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the statedb-backed quota.Store.
func (*Store) AdjustCounter ¶ added in v0.0.5
func (s *Store) AdjustCounter(identity string, res quota.Resource, bucket string, delta, limit float64, enforce bool, at time.Time) (float64, bool, error)
AdjustCounter adds delta to one counter atomically; see statedb.AdjustQuotaCounter. It makes this store a quota.AtomicStore, which is what lets several hub processes enforce one set of caps (Task 20354).
func (*Store) DeleteOverride ¶
DeleteOverride removes one identity's override.
func (*Store) LoadCounters ¶
func (s *Store) LoadCounters() ([]quota.CounterRow, error)
LoadCounters returns every persisted counter, stale day buckets included. pkg/quota decides which are still current — the storage layer holds no clock, so it cannot know what "today" means to the process reading it.
func (*Store) LoadOverrides ¶
LoadOverrides returns every per-identity override.
A row whose limits_json will not parse is skipped rather than failing the whole load. The alternative is a hub that refuses to start because one hand-edited row is malformed — and refusing to start is not the safe direction here: it takes down every tenant to protect one ceiling.
func (*Store) PruneCountersBefore ¶
PruneCountersBefore deletes daily counters older than bucket.
func (*Store) PutCounter ¶
func (s *Store) PutCounter(c quota.CounterRow) error
PutCounter writes one counter's value.
func (*Store) PutOverride ¶
PutOverride writes one identity's override.
func (*Store) ReplaceGauges ¶
func (s *Store) ReplaceGauges(rows []quota.CounterRow) error
ReplaceGauges swaps the whole gauge set atomically.