badgerstoreverified

package
v0.0.0-...-72fcfe4 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package badgerstoreverified provides the default verified register storage implementation using badger db.

Index

Constants

View Source
const (
	Prefix_User = iota

	Prefix_Rebinding
)

The second and third prefixes held the username and alias indexes until names moved to the binding store (register's ADR-017 §1), and are not reused, so a database written before then holds only entries nothing reads.

Variables

This section is empty.

Functions

This section is empty.

Types

type StorageOption

type StorageOption func(*VerifiedRegisterStorage)

func WithStoragePrefix

func WithStoragePrefix(prefix byte) StorageOption

WithStoragePrefix may be used to change the store's byte prefix. This allows the underlying database instance to be shared with other stores without key conflicts.

type VerifiedRegisterStorage

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

func NewVerifiedRegisterStorage

func NewVerifiedRegisterStorage(db *badger.DB, opts ...StorageOption) *VerifiedRegisterStorage

NewVerifiedRegisterStorage accepts an instance of BadgerDB and returns a pointer to the instantiated VerifiedRegisterStorage. It is the responsibility of the caller to manage the db instance.

func (*VerifiedRegisterStorage) DeleteRebindingTxn

func (vrs *VerifiedRegisterStorage) DeleteRebindingTxn(_ context.Context, userId ksuid.KSUID, itxn register.Txn) error

DeleteRebindingTxn deletes the user's rebinding within txn. A rebinding that was never there is absent on success.

func (*VerifiedRegisterStorage) DeleteUserTxn

func (vrs *VerifiedRegisterStorage) DeleteUserTxn(_ context.Context, userId ksuid.KSUID, itxn register.Txn) error

DeleteUserTxn deletes the user within txn. A user that was never there is absent on success, as the VerifiedRegisterStore contract requires.

func (*VerifiedRegisterStorage) ExistsById

func (vrs *VerifiedRegisterStorage) ExistsById(_ context.Context, userId ksuid.KSUID) (bool, error)

ExistsById reports whether the given Id exists. A read that fails other than by a missing key is returned, because it establishes nothing.

func (*VerifiedRegisterStorage) IncompleteRebindings

func (vrs *VerifiedRegisterStorage) IncompleteRebindings(_ context.Context) ([]ksuid.KSUID, error)

IncompleteRebindings returns the ids of every user holding a rebinding. It iterates keys only, and the store schedules nothing of its own.

func (*VerifiedRegisterStorage) NewTransaction

func (vrs *VerifiedRegisterStorage) NewTransaction(_ context.Context, update bool) (register.Txn, error)

func (*VerifiedRegisterStorage) RebindingTxn

func (vrs *VerifiedRegisterStorage) RebindingTxn(_ context.Context, userId ksuid.KSUID, itxn register.Txn) (*register.Rebinding, error)

RebindingTxn returns the user's rebinding within txn. Badger tracks the read, a key it did not find included, so a commit of txn is refused once another has written or deleted the rebinding since.

func (*VerifiedRegisterStorage) UserById

func (vrs *VerifiedRegisterStorage) UserById(_ context.Context, userId ksuid.KSUID) (*register.User, error)

UserById returns the user with the given id, outside any boundary, provided it exists. On failure an error is returned.

func (*VerifiedRegisterStorage) UserByIdTxn

func (vrs *VerifiedRegisterStorage) UserByIdTxn(_ context.Context, userId ksuid.KSUID, itxn register.Txn) (*register.User, error)

UserByIdTxn returns the user with the given id within txn. Badger tracks the read, a key it did not find included.

func (*VerifiedRegisterStorage) WriteRebindingTxn

func (vrs *VerifiedRegisterStorage) WriteRebindingTxn(_ context.Context, rebinding register.Rebinding, itxn register.Txn) error

WriteRebindingTxn writes the rebinding within txn, keyed by its user.

func (*VerifiedRegisterStorage) WriteUserTxn

func (vrs *VerifiedRegisterStorage) WriteUserTxn(_ context.Context, user register.User, itxn register.Txn) error

WriteUserTxn writes the user within txn.

Jump to

Keyboard shortcuts

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