statestore

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package statestore persists atomic protocol byte records in SQLite, PostgreSQL and MySQL.

Design

Security services use these records for grants, certificate associations, revocation and quota accounting across replicas. Transactions lock fixed shards in deterministic order before reading database time, bounding lock metadata and coordinating expiry decisions. The protocol-state schema has its own migrations. The caller owns the database pool and chooses serialization and namespaces through domain interfaces.

References

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MigrationSet

func MigrationSet(d sqlcommon.Dialect) (sqlcommon.MigrationSet, error)

MigrationSet exposes the schema to coordinated backup and restore tools.

func PublishCertificate

func PublishCertificate(ctx context.Context, tx state.Tx, identity lifecycle.Identity, material lifecycle.Material) error

PublishCertificate participates in the state transaction, so the runtime APNs identity and workflow activation are visible at the same commit.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store implements state.Store with SQL transactions and authoritative database time.

func Open

func Open(
	ctx context.Context,
	db *sql.DB,
	d sqlcommon.Dialect,
	keys ...*crypt.Keyring,
) (*Store, error)

Open applies the separate state schema migrations and wraps the caller's pool.

func (*Store) Get

func (s *Store) Get(ctx context.Context, k string) (state.Record, error)

Get implements state.Reader.

func (*Store) List

func (s *Store) List(ctx context.Context, prefix, after string, limit int) ([]state.Record, error)

List implements state.Reader.

func (*Store) Prune

func (s *Store) Prune(ctx context.Context, limit int) (int, error)

Prune uses the same shard locks as writers and rechecks expiry after locking.

func (*Store) Rewrap

func (s *Store) Rewrap(ctx context.Context) (int, error)

Rewrap rotates protocol state under the active key. Call until it returns zero.

func (*Store) Update

func (s *Store) Update(ctx context.Context, keys []string, fn func(state.Tx) error) error

Update locks fixed shards in ascending order. SQLite's initial UPDATE obtains its writer lock before any read, avoiding read-to-write upgrade races. PostgreSQL and MySQL use READ COMMITTED so reads after lock acquisition see the last commit.

Jump to

Keyboard shortcuts

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