sqlauth

package
v1.43.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Error = errs.Class("sqlauth")

Error is default error class for sqlauth package.

Functions

func BatchValues

func BatchValues(pkvals [][]byte, threshold int) ([][]byte, [][]byte)

BatchValues splits pkvals into two groups, where the first has a maximum length of threshold and the second contains the rest of the data.

Types

type KV

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

KV is a key/value store backed by a sql database.

func Open

func Open(ctx context.Context, log *zap.Logger, connstr string, opts Options) (_ *KV, err error)

Open creates instance of KV.

func OpenTest

func OpenTest(ctx context.Context, log *zap.Logger, name, connstr string) (*KV, error)

OpenTest creates an instance of KV suitable for testing.

func (*KV) Close

func (d *KV) Close() error

Close closes the connection to database.

func (*KV) Delete

func (d *KV) Delete(ctx context.Context, keyHash authdb.KeyHash) (err error)

Delete removes the record from the key/value store. It is not an error if the key does not exist.

func (*KV) DeleteUnused

func (d *KV) DeleteUnused(ctx context.Context, asOfSystemInterval time.Duration, selectSize, deleteSize int) (count, rounds int64, deletesPerHead map[string]int64, err error)

DeleteUnused deletes expired and invalid records from the key/value store in batches as specified by the selectSize and deleteSize parameters and returns any error encountered. It uses database time to avoid problems with invalid time on the server.

func (*KV) Get

func (d *KV) Get(ctx context.Context, keyHash authdb.KeyHash) (*authdb.Record, error)

Get retrieves the record from the key/value store.

func (*KV) GetWithNonDefaultAsOfInterval

func (d *KV) GetWithNonDefaultAsOfInterval(ctx context.Context, keyHash authdb.KeyHash, asOfSystemInterval time.Duration) (_ *authdb.Record, err error)

GetWithNonDefaultAsOfInterval retrieves the record from the key/value store using the specific asOfSystemInterval.

func (*KV) Invalidate

func (d *KV) Invalidate(ctx context.Context, keyHash authdb.KeyHash, reason string) (err error)

Invalidate causes the record to become invalid. It is not an error if the key does not exist. It does not update the invalid reason if the record is already invalid.

func (*KV) MigrateToLatest

func (d *KV) MigrateToLatest(ctx context.Context) (err error)

MigrateToLatest migrates the kv store to the latest version of the schema.

func (*KV) Migration

func (d *KV) Migration(ctx context.Context) *migrate.Migration

Migration returns table migrations. The SQL here represent the step-wise changes to the database.

func (*KV) PingDB added in v1.29.0

func (d *KV) PingDB(ctx context.Context) (err error)

PingDB attempts to do a database roundtrip and returns an error if it can't.

func (*KV) Put

func (d *KV) Put(ctx context.Context, keyHash authdb.KeyHash, record *authdb.Record) (err error)

Put is like PutAtTime, but it uses current time to store the record.

func (*KV) PutAtTime added in v1.37.1

func (d *KV) PutAtTime(ctx context.Context, keyHash authdb.KeyHash, record *authdb.Record, createdAt time.Time) (err error)

PutAtTime stores the record at a specific time. It is an error if the key already exists.

func (*KV) Run added in v1.29.0

func (d *KV) Run(ctx context.Context) error

Run runs the database.

func (*KV) Schema

func (d *KV) Schema() string

Schema returns the underlying database schema.

func (*KV) TagSQL

func (d *KV) TagSQL() tagsql.DB

TagSQL returns *tagsql.DB.

func (*KV) TestingSetCleanup

func (d *KV) TestingSetCleanup(cleanup func() error)

TestingSetCleanup is used to set the callback for cleaning up test database.

func (*KV) UnderlyingDB added in v1.30.0

func (d *KV) UnderlyingDB() *dbx.DB

UnderlyingDB returns the underlying database.

type Options

type Options struct {
	ApplicationName string
}

Options includes options for how a connection is made.

type RebindableTagSQL

type RebindableTagSQL struct {
	tagsql.DB
	// contains filtered or unexported fields
}

RebindableTagSQL offers a version of tagsql.DB which exposed a SQL Rebind() method.

func (RebindableTagSQL) Rebind

func (db RebindableTagSQL) Rebind(sql string) string

Rebind allows rewrites SQL parameter syntax as required in Migration.Run().

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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