postgres

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package postgres persists single-use recovery credentials through explicit migrations and generated queries. It borrows the application's existing pool.

Index

Constants

View Source
const (
	MigrationOrigin  migrate.Origin  = "foundry.challenges"
	CreateChallenges migrate.ID      = "000001_create_challenges"
	Introduced       migrate.Version = "v0.1.0"
)

Variables

This section is empty.

Functions

func Migrations

func Migrations() []migrate.Definition

Migrations must be registered and applied explicitly. Subject rows are stable synchronization records and are not garbage-collected by ordinary pruning.

Types

type Backend

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

func New

func New(db *database.DB, config Config) (*Backend, error)

func (*Backend) Consume

func (*Backend) Issue

func (b *Backend) Issue(ctx context.Context, address challenge.Address, identity model.Identity, hash challenge.Digest, lifetime time.Duration, prepare func(context.Context, *database.Tx) (challenge.Binding, error)) (challenge.Record, error)

func (*Backend) Prune

func (b *Backend) Prune(ctx context.Context, address challenge.Address, limit int) (uint64, error)

func (*Backend) Revoke

func (b *Backend) Revoke(ctx context.Context, address challenge.Address, identity model.Identity) (bool, error)

type Config

type Config struct {
	Schema string
	Clock  clock.Clock
}

Config's schema is shared by challenge and domain-model queries inside the callback. Instances must share synchronized clocks. Construction does no I/O.

func DefaultConfig

func DefaultConfig() Config

func (Config) Validate

func (c Config) Validate() error

Jump to

Keyboard shortcuts

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