badgerfood

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 15 Imported by: 1

README

badger datastore

Badger backend implementation of datastore interface

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultValueLogMaxEntries  = uint32(1024 * 1024 * 1024)
	DefaultKeyRotationDuration = time.Hour * 24 * 7

	ErrTransactionCanceled         = errors.New("transaction was canceled")
	ErrInvalidTransactionInContext = errors.New("incompatible transaction in context")
)
View Source
var BadgerStoreClass = reflect.TypeOf((*implBadgerStore)(nil))

Functions

func FromDB

func FromDB(name string, db *badger.DB) *implBadgerStore

func New

func New(name string, dataDir string, options ...Option) (*implBadgerStore, error)

func NewLogger

func NewLogger(debug bool) badger.Logger

func NewTransaction

func NewTransaction(tx *badger.Txn, readOnly bool) fastfood.Transaction

func NewZapLogger

func NewZapLogger(log *zap.Logger, debug bool) badger.Logger

func ObjectType

func ObjectType() reflect.Type

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures badger using the functional options paradigm popularized by Rob Pike and Dave Cheney. If you're unfamiliar with this style, see https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html and https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis.

func WithBaseLevelSize

func WithBaseLevelSize(value int64) Option

func WithBaseTableSize

func WithBaseTableSize(value int64) Option

func WithBlockCacheSize

func WithBlockCacheSize(value int64) Option

func WithBlockSize

func WithBlockSize(value int) Option

Changing BlockSize across DB runs will not break badger. The block size is read from the block index stored at the end of the table.

func WithBloomFalsePositive

func WithBloomFalsePositive(value float64) Option

func WithChecksumVerificationMode

func WithChecksumVerificationMode(mode options.ChecksumVerificationMode) Option

ChecksumVerificationMode decides when db should verify checksums for SSTable blocks.

func WithCompactL0OnClose

func WithCompactL0OnClose() Option

func WithCompression

func WithCompression(zstd bool) Option

func WithConcurrentRetryNum

func WithConcurrentRetryNum(value int) Option

func WithDataDir

func WithDataDir(dataDir string) Option

func WithDetectConflicts

func WithDetectConflicts() Option

DetectConflicts determines whether the transactions would be checked for conflicts. The transactions can be processed at a higher rate when conflict detection is disabled.

func WithEncryptionKey

func WithEncryptionKey(storageKey []byte) Option

func WithInMemory

func WithInMemory() Option

func WithIndexCacheSize

func WithIndexCacheSize(value int64) Option

func WithKeyValueDir

func WithKeyValueDir(dataDir string) Option

func WithLBypassLockGuard

func WithLBypassLockGuard() Option

BypassLockGaurd will bypass the lock guard on badger. Bypassing lock guard can cause data corruption if multiple badger instances are using the same directory. Use this options with caution.

func WithLevelSizeMultiplier

func WithLevelSizeMultiplier(value int) Option

func WithLmaxCompaction

func WithLmaxCompaction() Option

func WithLogger

func WithLogger(debug bool) Option

func WithMaxLevels

func WithMaxLevels(value int) Option

func WithMaxPendingWrites

func WithMaxPendingWrites(value int) Option

func WithMemTableSize

func WithMemTableSize(value int64) Option

func WithMetricsEnabled

func WithMetricsEnabled() Option

func WithNamespaceOffset

func WithNamespaceOffset(value int) Option

func WithNope

func WithNope() Option

option that do nothing

func WithNumCompactors

func WithNumCompactors(value int) Option

func WithNumGoroutines

func WithNumGoroutines(value int) Option

func WithNumLevelZeroTables

func WithNumLevelZeroTables(value int) Option

func WithNumLevelZeroTablesStall

func WithNumLevelZeroTablesStall(value int) Option

func WithNumMemtables

func WithNumMemtables(value int) Option

func WithNumVersionsToKeep

func WithNumVersionsToKeep(num int) Option

func WithOpenTimeout

func WithOpenTimeout(timeout time.Duration) Option

func WithReadOnly

func WithReadOnly() Option

func WithSnappy

func WithSnappy() Option

func WithSyncWrites

func WithSyncWrites() Option

func WithTableSizeMultiplier

func WithTableSizeMultiplier(value int) Option

func WithVLogPercentile

func WithVLogPercentile(value float64) Option

func WithValueLogFileSize

func WithValueLogFileSize(value int64) Option

func WithValueLogMaxEntries

func WithValueLogMaxEntries(value uint32) Option

func WithValueThreshold

func WithValueThreshold(threshold int64) Option

func WithVerifyValueChecksum

func WithVerifyValueChecksum() Option

When set, checksum will be validated for each entry read from the value log file.

func WithZapLogger

func WithZapLogger(log *zap.Logger, debug bool) Option

type StoreOptions

type StoreOptions struct {
	OpenTimeout        time.Duration
	MaxPendingWrites   int
	ConcurrentRetryNum int
}

func DefaultStoreOptions

func DefaultStoreOptions() *StoreOptions

func OpenDatabase

func OpenDatabase(dataDir string, options ...Option) (*badger.DB, *StoreOptions, error)

Jump to

Keyboard shortcuts

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