quotastore

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 4 Imported by: 0

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

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 New

func New(db *statedb.DB) (*Store, error)

New wraps an open state database.

func (*Store) DeleteOverride

func (s *Store) DeleteOverride(identity string) (bool, error)

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

func (s *Store) LoadOverrides() ([]quota.Override, error)

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

func (s *Store) PruneCountersBefore(bucket string) error

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

func (s *Store) PutOverride(o quota.Override) error

PutOverride writes one identity's override.

func (*Store) ReplaceGauges

func (s *Store) ReplaceGauges(rows []quota.CounterRow) error

ReplaceGauges swaps the whole gauge set atomically.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL