boltdb

package
v3.32.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: Apache-2.0, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package boltdb contains the boltdb implementations of the DAX interfaces.

Index

Constants

View Source
const (
	ErrFmtBucketNotFound = "boltdb: bucket '%s' not found"
)

Variables

View Source
var DirectiveBuckets []Bucket = []Bucket{
	bucketDirective,
}

DirectiveBuckets defines the buckets used by this package. It can be called during setup to create the buckets ahead of time.

Functions

This section is empty.

Types

type Bucket

type Bucket []byte

type DB

type DB struct {

	// Datasource name.
	DSN string

	// Returns the current time. Defaults to time.Now().
	// Can be mocked for tests.
	Now func() time.Time
	// contains filtered or unexported fields
}

DB represents the database connection.

func NewDB

func NewDB(dsn string) *DB

NewDB returns a new instance of DB associated with the given datasource name.

func NewSvcBolt

func NewSvcBolt(dir, svc string, buckets ...Bucket) (*DB, error)

NewSvcBolt gets, opens, and creates buckets for a boltDB for a particular named service (the data file will be named after the service).

func (*DB) BeginTx

func (db *DB) BeginTx(ctx context.Context, writable bool) (*Tx, error)

BeginTx starts a transaction and returns a wrapper Tx type. This type provides a reference to the database and a fixed timestamp at the start of the transaction. The timestamp allows us to mock time during tests as well. The wrapper also contains the context.

func (*DB) Close

func (db *DB) Close() (err error)

Close closes the database connection.

func (*DB) InitializeBuckets

func (db *DB) InitializeBuckets(buckets ...Bucket) (err error)

InitializeBuckets creates the given buckets if they do not already exist.

func (*DB) Open

func (db *DB) Open() (err error)

Open opens the database connection.

func (*DB) Path

func (db *DB) Path() string

func (*DB) RegisterBuckets

func (db *DB) RegisterBuckets(buckets ...Bucket)

RegisterBuckets queues up the buckets to be created when the database is first opened.

type DirectiveVersion

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

func NewDirectiveVersion

func NewDirectiveVersion(db *DB) *DirectiveVersion

func (*DirectiveVersion) Increment

func (d *DirectiveVersion) Increment(tx dax.Transaction, delta uint64) (uint64, error)

type Tx

type Tx struct {
	*bolt.Tx
	// contains filtered or unexported fields
}

Tx wraps the SQL Tx object to provide a timestamp at the start of the transaction.

func (*Tx) Context added in v3.29.0

func (tx *Tx) Context() context.Context

Jump to

Keyboard shortcuts

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