Documentation
¶
Overview ¶
Package sqlite provides a SQLite-backed crypto.KeyStore for the synapse event-sourcing toolkit.
Schema:
keys(subject PK, dek BLOB NULL, shredded_at INTEGER NULL)
Shred sets dek = NULL and shredded_at = now(ns). A tombstoned row outlives the key — that's what makes "already shredded" distinct from "never seen" to the keystore implementation. Both surface as crypto.ErrKeyShredded to callers, because they are indistinguishable to a consumer that doesn't hold the key.
The package blank-imports modernc.org/sqlite to register the pure-Go driver. WAL + busy_timeout + _txlock=immediate are strongly recommended for concurrent workloads (see eventstore/sqlite for the full rationale).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Schema string
Schema is the SQL DDL this Store requires. It is exported so users who manage migrations externally (goose, golang-migrate, atlas, etc.) can feed it to their own tooling. New applies it by default; WithoutMigrate disables that. Migrate applies it explicitly.
Functions ¶
Types ¶
type Option ¶
type Option func(*options)
Option configures New.
func WithoutMigrate ¶
func WithoutMigrate() Option
WithoutMigrate disables the automatic schema migration that New performs by default.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a SQLite-backed crypto.KeyStore.
The caller owns the underlying *sql.DB and is responsible for closing it.
func New ¶
New returns a Store wrapping db. By default applies Schema; pass WithoutMigrate to skip when migrations are external.
func (*Store) Get ¶
Get implements crypto.KeyStore. Returns ErrKeyShredded both for tombstoned subjects and for never-seen subjects.
func (*Store) GetOrCreate ¶
GetOrCreate implements crypto.KeyStore. Returns ErrKeyShredded if subject has previously been Shred-ded; otherwise creates a fresh 32-byte DEK on first use and returns the existing one thereafter.
Concurrent first-calls for the same subject race on the unique constraint; the loser falls back to a SELECT and returns the existing row.