Documentation
¶
Overview ¶
Package postgres provides durable atomic capability consumption through database/sql and PostgreSQL row locks. The caller supplies the SQL driver.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrateLegacyConsumption ¶
MigrateLegacyConsumption upgrades migration 001 to the issuer-scoped schema version 2, preserving every use count, maximum and expiry. legacyIssuer must be the owner-proven single issuer of all existing rows, never a token claim. The caller must fence and drain all old writers first and supply an open transaction. This function locks the table but does not commit or roll back; on failure the caller must roll back. Commit before activating new writers. An already upgraded schema is not migrated again. Unknown legacy ownership requires retiring old grants beyond expiry plus verification skew instead.
Types ¶
type ConsumptionStore ¶
type ConsumptionStore struct {
// contains filtered or unexported fields
}
ConsumptionStore owns durable PostgreSQL transactions for replay state.
func NewConsumptionStore ¶
func NewConsumptionStore(db *sql.DB) (*ConsumptionStore, error)
NewConsumptionStore binds store to db. The schema in migrations must be installed and MigrateLegacyConsumption committed before use. db remains caller-owned and is never closed here.
func (*ConsumptionStore) Consume ¶
func (store *ConsumptionStore) Consume(ctx context.Context, request capability.Consumption) (capability.ConsumptionResult, error)
Consume serializes one capability row, then commits an increment only when the signed identity and use bound match. Commit errors have unknown outcome.