sql

package
v0.0.0-...-5eca219 Latest Latest
Warning

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

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

Documentation

Overview

Package sql implements Inventory and NonceChecker backed by SQL database.

Supports at least PostgreSQL 9.5+ (github.com/lib/pq) and SQLite 3.24+ (modernc.org/sqlite, github.com/mattn/go-sqlite3).

Index

Constants

View Source
const InventorySchema = `
CREATE TABLE IF NOT EXISTS module_source (
	module TEXT NOT NULL,
	source TEXT NOT NULL,

	PRIMARY KEY (source)
);
`
View Source
const NonceSchema = `` /* 198-byte string literal not displayed */

Variables

View Source
var Adapter = database.Register(&database.Adapter{
	Name: "sql",

	NewConfig: func() database.Config {
		return &adaptedConfig{
			Config: DefaultConfig.Clone(),
		}
	},

	Open: func(config database.Config) (database.Endpoint, error) {
		x, err := Open(config.(*adaptedConfig).Config)
		if err != nil {
			return nil, err
		}
		return x, err
	},

	InitInventory: func(ctx context.Context, endpoint database.Endpoint) (database.Inventory, error) {
		x := endpoint.(*Endpoint)
		if err := x.InitInventory(ctx); err != nil {
			return nil, err
		}
		return x, nil
	},

	InitNonceChecker: func(ctx context.Context, endpoint database.Endpoint) (database.NonceChecker, error) {
		x := endpoint.(*Endpoint)
		if err := x.InitNonceChecker(ctx); err != nil {
			return nil, err
		}
		return x, nil
	},
})

Functions

This section is empty.

Types

type Config

type Config struct {
	Driver string
	DSN    string
}
var DefaultConfig Config

func (*Config) Clone

func (c *Config) Clone() Config

func (*Config) Enabled

func (c *Config) Enabled() bool

func (*Config) Equal

func (c *Config) Equal(other Config) bool

type Endpoint

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

func Open

func Open(config Config) (*Endpoint, error)

func (*Endpoint) AddModuleSource

func (x *Endpoint) AddModuleSource(ctx context.Context, module, source string) error

func (*Endpoint) CheckNonce

func (x *Endpoint) CheckNonce(ctx context.Context, scope []byte, nonce string, expire time.Time) error

func (*Endpoint) Close

func (x *Endpoint) Close() error

func (*Endpoint) GetSourceModule

func (x *Endpoint) GetSourceModule(ctx context.Context, source string) (string, error)

func (*Endpoint) InitInventory

func (x *Endpoint) InitInventory(ctx context.Context) error

func (*Endpoint) InitNonceChecker

func (x *Endpoint) InitNonceChecker(ctx context.Context) error

Jump to

Keyboard shortcuts

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