Documentation
¶
Overview ¶
Package state defines transactional, expiring byte records for protocol state.
Design ¶
Token exchange, certificate associations, revocation and quotas need atomic updates without importing database drivers. Memory supports a single process, while server/statestore provides shared SQL persistence. Transactions expose store time so expiry and quota decisions can use a consistent clock. Callers own serialization, namespaces, key selection and record lifetimes. In-memory state is lost on restart.
References ¶
Index ¶
- Variables
- func ValidKey(k string) bool
- type Memory
- func (m *Memory) Get(ctx context.Context, key string) (Record, error)
- func (m *Memory) List(ctx context.Context, prefix, after string, limit int) ([]Record, error)
- func (m *Memory) Prune(ctx context.Context, limit int) (int, error)
- func (m *Memory) Update(ctx context.Context, keys []string, fn func(Tx) error) error
- type Reader
- type Record
- type Store
- type Tx
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("state: record not found") ErrInvalid = errors.New("state: invalid key or transaction") )
Functions ¶
Types ¶
type Memory ¶
Memory is a serializable store. Now may be set before use for deterministic tests.
type Reader ¶
type Reader interface {
Get(context.Context, string) (Record, error)
// List returns up to limit records in key order, strictly after after.
List(ctx context.Context, prefix, after string, limit int) ([]Record, error)
}
Reader reads records, including expired ones; protocol callers validate expiry.
type Store ¶
type Store interface {
Reader
Update(ctx context.Context, keys []string, fn func(Tx) error) error
// Prune deletes at most limit expired records. It never deletes immortal data.
Prune(ctx context.Context, limit int) (int, error)
}
Store commits all writes in a callback or none. Updates sharing any lock key serialize; callers must use the same lock keys for every writer of a record. Keys may designate a whole logical group (for example an issuer's CRL).