boltdb

package
v3.26.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: Apache-2.0 Imports: 15 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.

View Source
var NodeServiceBuckets []Bucket = []Bucket{
	bucketNodes,
}

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

View Source
var VersionStoreBuckets []Bucket = []Bucket{
	bucketTables,
	bucketShards,
	bucketTableKeys,
	bucketFieldKeys,
}

VersionStoreBuckets 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.

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(ctx context.Context, delta uint64) (uint64, error)

type NodeService

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

NodeService represents a service for managing nodes.

func NewNodeService

func NewNodeService(db *DB, logger logger.Logger) *NodeService

NewNodeService returns a new instance of NodeService with default values.

func (*NodeService) CreateNode

func (s *NodeService) CreateNode(ctx context.Context, addr dax.Address, node *dax.Node) error

func (*NodeService) DeleteNode

func (s *NodeService) DeleteNode(ctx context.Context, addr dax.Address) error

func (*NodeService) Nodes

func (s *NodeService) Nodes(ctx context.Context) ([]*dax.Node, error)

func (*NodeService) ReadNode

func (s *NodeService) ReadNode(ctx context.Context, addr dax.Address) (*dax.Node, 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.

type VersionStore

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

VersionStore manages all version info for shard, table keys, and field keys.

func NewVersionStore

func NewVersionStore(db *DB, logger logger.Logger) *VersionStore

NewVersionStore returns a new instance of VersionStore with default values.

func (*VersionStore) AddFields

func (s *VersionStore) AddFields(ctx context.Context, qtid dax.QualifiedTableID, fields ...dax.VersionedField) error

AddFields adds new fields to be managed by VersionStore. It returns the number of fields added or an error.

func (*VersionStore) AddPartitions

func (s *VersionStore) AddPartitions(ctx context.Context, qtid dax.QualifiedTableID, partitions ...dax.VersionedPartition) error

AddPartitions adds new partitions to be managed by VersionStore. It returns the number of partitions added or an error.

func (*VersionStore) AddShards

func (s *VersionStore) AddShards(ctx context.Context, qtid dax.QualifiedTableID, shards ...dax.VersionedShard) error

func (*VersionStore) AddTable

func (s *VersionStore) AddTable(ctx context.Context, qtid dax.QualifiedTableID) error

func (*VersionStore) Copy

Copy returns an in-memory copy of VersionStore.

func (*VersionStore) FieldTables

func (s *VersionStore) FieldTables(ctx context.Context, qual dax.TableQualifier) (dax.TableIDs, error)

func (*VersionStore) FieldVersion

func (s *VersionStore) FieldVersion(ctx context.Context, qtid dax.QualifiedTableID, field dax.FieldName) (int, bool, error)

func (*VersionStore) Fields

func (*VersionStore) PartitionTables

func (s *VersionStore) PartitionTables(ctx context.Context, qual dax.TableQualifier) (dax.TableIDs, error)

func (*VersionStore) PartitionVersion

func (s *VersionStore) PartitionVersion(ctx context.Context, qtid dax.QualifiedTableID, partitionNum dax.PartitionNum) (int, bool, error)

func (*VersionStore) Partitions

func (*VersionStore) RemoveTable

func (*VersionStore) ShardTables

func (s *VersionStore) ShardTables(ctx context.Context, qual dax.TableQualifier) (dax.TableIDs, error)

func (*VersionStore) ShardVersion

func (s *VersionStore) ShardVersion(ctx context.Context, qtid dax.QualifiedTableID, shardNum dax.ShardNum) (int, bool, error)

ShardVersion return the current version for the given table/shardNum. If a version is not being tracked, it returns a bool value of false.

func (*VersionStore) Shards

Jump to

Keyboard shortcuts

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