badgerauthmigration

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: 12 Imported by: 0

Documentation

Overview

Package badgerauthmigration helps move to badgerauth from sqlauth.

Index

Constants

This section is empty.

Variables

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

Error is the default error class for the badgerauthmigration package.

Functions

This section is empty.

Types

type Config

type Config struct {
	MigrationSelectSize    int    `user:"true" help:"page size while performing migration"                 default:"1000"`
	SourceSQLAuthKVBackend string `user:"true" help:"source key/value store backend (must be sqlauth) url" default:""`
}

Config represents config for KV.

type KV

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

KV is an implementation of the KV interface that helps move from sqlauth to badgerauth backend by incorporating both, implementing migration and proxying requests to both backends to avoid downtime.

func New

func New(log *zap.Logger, src *sqlauth.KV, dst *badgerauth.Node, config Config) *KV

New constructs new KV.

func (*KV) Close

func (kv *KV) Close() (err error)

Close closes the database.

func (*KV) DeleteUnused

func (*KV) DeleteUnused(context.Context, time.Duration, int, int) (int64, int64, map[string]int64, error)

DeleteUnused is not implemented.

func (*KV) Get

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

Get retrieves the record from the key/value store. It returns nil if the key does not exist. If the record is invalid, the error contains why.

func (*KV) MigrateToLatest

func (kv *KV) MigrateToLatest(ctx context.Context) error

MigrateToLatest migrates all existing records at passed sqlauth to the new badgerauth backend.

func (*KV) PingDB

func (kv *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 (kv *KV) Put(ctx context.Context, keyHash authdb.KeyHash, record *authdb.Record) (err error)

Put stores the record. It is an error if the key already exists.

We write to both stores to ensure we can perform a rollback in case of anything.

func (*KV) Run

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

Run runs the server and the associated servers.

Jump to

Keyboard shortcuts

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