database

package
v0.0.0-...-5716353 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoConfig = errors.New("no database configuration")
View Source
var ErrNonceReused = errors.New("nonce reused")

Functions

func Adapters

func Adapters() map[string]*Adapter

func NewInventoryConfigs

func NewInventoryConfigs() map[string]Config

func NewNonceCheckerConfigs

func NewNonceCheckerConfigs() map[string]Config

Types

type Adapter

type Adapter struct {
	Name             string
	NewConfig        func() Config
	Open             func(Config) (Endpoint, error)
	InitInventory    func(context.Context, Endpoint) (Inventory, error)
	InitNonceChecker func(context.Context, Endpoint) (NonceChecker, error)
}

func Register

func Register(a *Adapter) *Adapter

func (*Adapter) String

func (a *Adapter) String() string

type Config

type Config interface {
	Enabled() bool
	Equal(Config) bool
}

type DB

type DB struct {
	Adapter *Adapter
	Config  Config
	// contains filtered or unexported fields
}

func Open

func Open(name string, config Config) (*DB, error)

func Resolve

func Resolve(configs map[string]Config) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) InitInventory

func (db *DB) InitInventory(ctx context.Context) (Inventory, error)

func (*DB) InitNonceChecker

func (db *DB) InitNonceChecker(ctx context.Context) (NonceChecker, error)

type Endpoint

type Endpoint interface {
	io.Closer
}

type Inventory

type Inventory interface {
	GetSourceModule(ctx context.Context, source string) (module string, err error)
	AddModuleSource(ctx context.Context, module, source string) error
}

type NonceChecker

type NonceChecker interface {
	CheckNonce(ctx context.Context, scope []byte, nonce string, expires time.Time) error
}

Directories

Path Synopsis
Package sql implements Inventory and NonceChecker backed by SQL database.
Package sql implements Inventory and NonceChecker backed by SQL database.

Jump to

Keyboard shortcuts

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