dbadger

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 28 Imported by: 0

README

DBadger

Go Reference Go Report Card ci-dbadger Coverage Status

Logo

DBadger is a distributed embeddable key-value database based on BadgerDB persistent storage and Raft consensus algorithm.

DBadger:

  • Uses BadgerDB as both data store and log store and simple fsync-ed file for stable store.
  • Uses GRPC for inter-node communication and redirects requests to the leader node when neccessary.
  • Reuses single port for both Raft and GRPC by multiplexing TCP streams.
  • Supports communication over TLS between nodes.

Rationale

The purpose of this package is to make a simple distributed key-value store similar to etcd that is designed to be embeded into a program. This is mostly expiremental at this stage, so no API stability guarantees until v1.

Usage

config := dbadger.DefaultConfig("./datapath", "127.0.0.1:7001").WithBootstrap(true)
db, err := dbadger.Start(config)
if err != nil {
  log.Fatal(err)
}

// Run your application
db.Set(context.TODO(), []byte("key"), []byte("value"))
db.Get(context.TODO(), []byte("key"), dbadger.Eventual)

if err := db.Close(); err != nil {
  log.Fatal(err)
}

CLI Example

cmd/example-cli is a simple terminal UI node example, showing key-value pairs, cluster nodes, stats and logs for the node. See go run ./cmd/example-cli -h or cmd/example-cli/main.go for available flags.

Launching cluster
# Bootstrap first node
go run ./cmd/example-cli --db .data/db1 --bind 127.0.0.1:7001 --bootstrap

# Join follower nodes
go run ./cmd/example-cli --db .data/db2 --bind 127.0.0.1:7002 --join 127.0.0.1:7001

go run ./cmd/example-cli --db .data/db3 --bind 127.0.0.1:7003 --join 127.0.0.1:7001
Recovering cluster

To recover cluster from a single node, use:

go run ./cmd/example-cli --db .data/db1 --bind 127.0.0.1:7001 --recover

After the recovery the recovered node will be a new leader, and you will be able to join new clean nodes to this cluster.

TLS
# Bootstrap first node
go run ./cmd/example-cli --db .data/db1 --ca .tls/ca.crt --cert .tls/server1.lan.crt --key .tls/server1.lan.pem --bind 127.0.0.1:7001 --bootstrap

# Join follower nodes
go run ./cmd/example-cli --db .data/db2 --ca .tls/ca.crt --cert .tls/server2.lan.crt --key .tls/server2.lan.pem --bind 127.0.0.1:7002 --join 127.0.0.1:7001
go run ./cmd/example-cli --db .data/db3 --ca .tls/ca.crt --cert .tls/server3.lan.crt --key .tls/server3.lan.pem --bind 127.0.0.1:7003 --join 127.0.0.1:7001

Operations

Get

func (db *DB) Get(ctx context.Context, key []byte, readPreference ReadPreference) ([]byte, error)

Get returns value corresponding to the given key.

val, err := db.Get(context.TODO(), key, dbadger.LeaderPreference)
GetMany

func (db *DB) GetMany(ctx context.Context, keys [][]byte, readPreference ReadPreference) (values [][]byte, _ error)

GetMany returns values corresponding to the given keys.

keys := [][]byte{[]byte("key1"), []byte("key2"), []byte("key3")}
values, err := db.GetMany(context.TODO(), keys, dbadger.LeaderPreference)
GetPrefix

func (db *DB) GetPrefix(ctx context.Context, prefix []byte, readPreference ReadPreference) (keys, values [][]byte, _ error)

GetPrefix returns values for the keys with the given prefix.

values, err := db.GetPrefix(context.TODO(), []byte("prefix_"), dbadger.LeaderPreference)
GetRange

func (db *DB) GetRange(ctx context.Context, min, max []byte, count uint64, readPreference ReadPreference) (keys, values [][]byte, _ error)

GetRange returns maximum of count values for the keys in range [min, max]. Both min and max can be nil.

keys, values, err := db.GetRange(context.TODO(), []byte("key1"), nil, 10)
Set

func (db *DB) Set(ctx context.Context, key, value []byte) error

Set adds a key-value pair.

err := db.Set(context.TODO(), []byte("key"), []byte("value"))
SetMany

func (db *DB) SetMany(ctx context.Context, keys, values [][]byte) error

SetMany adds multiple key-value pairs.

Delete

func (db *DB) Delete(ctx context.Context, key []byte) error

Delete removes a key.

DeleteMany

func (db *DB) DeleteMany(ctx context.Context, keys [][]byte) error

DeleteMany removes multiple keys.

DeletePrefix

func (db *DB) DeletePrefix(ctx context.Context, prefix []byte) error

DeletePrefix removes keys with the given prefix.

DeleteRange

func (db *DB) DeleteRange(ctx context.Context, min, max []byte) (keys [][]byte, _ error)

DeleteRange removes keys in range [min, max] and returns keys that has been removed.

DeleteAll

func (db *DB) DeleteAll(ctx context.Context) error

DeleteAll removes all keys.

Snapshot

func (db *DB) Snapshot() (id string, err error)

Snapshot forces DB to take a snapshot, e.g. for backup purposes. Returns snapshot id and error, if any.

Restore

func (db *DB) Restore(id string) error

Restore forces DB to consume a snapshot, such as if restoring from a backup. This should not be used in normal operation, only for disaster recovery onto a new cluster.

Contributing

Any contributions are welcome in the form of issues and pull requests in this repository.

Documentation

Overview

Package dbadger provies a distributed embeddable key-value database based on BadgerDB persistent storage and Raft consensus algorithm.

  • Uses BadgerDB as both data store and log store and simple fsync-ed file for stable store.
  • Uses GRPC for inter-node communication and redirects requests to the leader node when necessary.
  • Listens on a single port for both Raft and GRPC traffic by multiplexing TCP streams.

The main type in dbadger is DB that must be started with Start.

Usage

config := dbadger.DefaultConfig("./datapath", "127.0.0.1:7001").WithBootstrap(true)
db, err := dbadger.Start(config)
if err != nil {
	log.Fatal(err)
}

// Run your application
db.Set(context.TODO(), []byte("key"), []byte("value"))
db.Get(context.TODO(), []byte("key"), dbadger.Eventual)

if err := db.Close(); err != nil {
	log.Fatal(err)
}

See the README.md, examples and tests for information.

Index

Constants

View Source
const (
	// LeaderPreference tells DB to read data from the current cluster leader.
	// This ensures that no stale data is returned from the read operation.
	LeaderPreference = rpc.ReadPreference_LEADER

	// LocalPreference tells DB to read data from the current node.
	// This is faster than routing request to the leader, but may return stale data.
	LocalPreference = rpc.ReadPreference_LOCAL
)

Variables

View Source
var (
	// ErrNoLeader is returned if a cluster has no leader or the leader is unknown at the moment.
	ErrNoLeader = errors.New("cluster has no leader")

	// ErrEmptyKey is returned if an empty key is passed to a write operation.
	ErrEmptyKey = errors.New("key can not be empty")
	// ErrInvalidKey is returned if the key has a special !badger! prefix, reserved for internal usage.
	ErrInvalidKey = errors.New("key is using a reserved !badger! prefix")
	// ErrNotFound is returned when key is not found in read operations.
	ErrNotFound = errors.New("key not found")

	// ErrInvalidRequest is returned if the user request is invalid.
	ErrInvalidRequest = errors.New("invalid request")

	// ErrConflict is returned when a transaction conflicts with another transaction. This can
	// happen if the read rows had been updated concurrently by another transaction.
	ErrConflict = errors.New("transaction conflict, please retry")

	// ErrUnavailable is returned when the cluster is currently unable to perform the
	// requested operation, but the operation should be retried with a backoff.
	// This can mean network errors, blocked writes during DeleteAll, etc.
	ErrUnavailable = errors.New("operation is currently unavailable, please retry")

	ErrInternal = errors.New("internal error")
)

Errors that can be returned from DB methods.

Functions

This section is empty.

Types

type Address

type Address string

Address is a network address of a DB node.

type Config

type Config struct {
	// Path is the path of the directory where data will be stored in. If directory does not exists it will be created.
	Path string

	// Bind is a network address for the node to listen on (for example, "127.0.0.1:7001", "[::1]:7001", ":7001").
	Bind Address

	// TLS configures certificates and keys for the node.
	//
	// Zero value means TLS is disabled.
	TLS TLSConfig

	// InMemory makes node run in in-memory mode, which means everything is stored in memory and no files are created.
	//
	// All data will be lost when node is stopped or crashed. Used primarily for testing purposes.
	InMemory bool

	// Bootstrap a new cluster from this node.
	//
	// A cluster should only be bootstrapped once from a single primary node.
	// After that other nodes can join the cluster.
	Bootstrap bool

	// Recover cluster from a loss of quorum (e.g. when multiple nodes die at the same time)
	// by forcing a new cluster configuration. This works by reading all the current state
	// for this node, creating a snapshot with the new configuration, and then truncating the log.
	//
	// Typically to bring the cluster back up you should choose a node to become a new leader,
	// recover that node and then join new clean-sate nodes as usual.
	Recover bool

	// Join an existing cluster via given node.
	//
	// It is safe to join a cluster via any node. If the target node is not a leader of the cluster
	// it will forward the request to the cluster's leader.
	Join Address

	// HeartbeatTimeout specifies the time in follower state without contact from a leader before
	// Raft attempts an election.
	HeartbeatTimeout time.Duration

	// ElectionTimeout specifies the time in candidate state without contact from a leader before
	// Raft attempts an election.
	ElectionTimeout time.Duration

	// LeaderLeaseTimeout is used to control how long the lease lasts for being the leader without
	// being able to contact a quorum of nodes. If we reach this interval without contact,
	// the node will step down as leader.
	LeaderLeaseTimeout time.Duration

	// CommitTimeout specifies the time without an Apply operation before the leader sends an
	// AppendEntry RPC to followers, to ensure a timely commit of log entries.
	CommitTimeout time.Duration

	// SnapshotInterval controls how often Raft checks if it should perform a snapshot.
	//
	// Raft randomly staggers between this value and 2x this value to avoid the entire cluster
	// from performing a snapshot at once.
	SnapshotInterval time.Duration

	// SnapshotThreshold controls how many outstanding logs there must be before Raft performs a snapshot.
	//
	// This is to prevent excessive snapshotting by replaying a small set of logs instead.
	SnapshotThreshold uint64

	// SnapshotRetention controls how many snapshots are retained. Must be at least 1.
	SnapshotRetention int

	// TrailingLogs controls how many logs Raft leaves after a snapshot.
	//
	// This is used so that a follower can quickly replay logs instead of being forced
	// to receive an entire snapshot.
	TrailingLogs uint64

	// LogStoreConfig configures replicated log storage.
	LogStoreConfig *StoreConfig

	// DataStoreConfig configures data storage.
	DataStoreConfig *StoreConfig

	// Logger configures which logger DB uses.
	//
	// Leaving this nil will disable logging.
	Logger Logger
}

Config is DBadger node config.

See DefaultConfig for defaults.

func DefaultConfig

func DefaultConfig(path string, bind Address) *Config

DefaultConfig return default Config.

func DefaultConfigInMemory

func DefaultConfigInMemory(bind Address) *Config

DefaultConfigInMemory returns default Config with InMemory mode turned on.

func (*Config) WithBootstrap

func (c *Config) WithBootstrap(bootstrap bool) *Config

WithBootstrap returns Config with Bootstrap set to the given value.

func (*Config) WithCommitTimeout added in v0.1.1

func (c *Config) WithCommitTimeout(v time.Duration) *Config

WithCommitTimeout returns Config with CommitTimeout set to the given value.

func (*Config) WithDataStoreConfig added in v0.1.1

func (c *Config) WithDataStoreConfig(v *StoreConfig) *Config

WithDataStoreConfig returns Config with DataStoreConfig set to the given value.

func (*Config) WithElectionTimeout added in v0.1.1

func (c *Config) WithElectionTimeout(v time.Duration) *Config

WithElectionTimeout returns Config with ElectionTimeout set to the given value.

func (*Config) WithHeartbeatTimeout added in v0.1.1

func (c *Config) WithHeartbeatTimeout(v time.Duration) *Config

WithHeartbeatTimeout returns Config with HeartbeatTimeout set to the given value.

func (*Config) WithInMemory

func (c *Config) WithInMemory(inmem bool) *Config

WithInMemory returns Config with InMemory set to the given value.

func (*Config) WithJoin

func (c *Config) WithJoin(join Address) *Config

WithJoin returns Config with Join set to the given value.

func (*Config) WithLeaderLeaseTimeout added in v0.1.1

func (c *Config) WithLeaderLeaseTimeout(v time.Duration) *Config

WithLeaderLeaseTimeout returns Config with LeaderLeaseTimeout set to the given value.

func (*Config) WithLogStoreConfig added in v0.1.1

func (c *Config) WithLogStoreConfig(v *StoreConfig) *Config

WithLogStoreConfig returns Config with LogStoreConfig set to the given value.

func (*Config) WithLogger

func (c *Config) WithLogger(logger Logger) *Config

WithLogger returns Config with Logger set to the given value.

func (*Config) WithRecover

func (c *Config) WithRecover(recover bool) *Config

WithRecover returns Config with Recover set to the given value.

func (*Config) WithSnapshotInterval added in v0.1.1

func (c *Config) WithSnapshotInterval(v time.Duration) *Config

WithSnapshotInterval returns Config with SnapshotInterval set to the given value.

func (*Config) WithSnapshotRetention added in v0.1.1

func (c *Config) WithSnapshotRetention(v int) *Config

WithSnapshotRetention returns Config with SnapshotRetention set to the given value.

func (*Config) WithSnapshotThreshold added in v0.1.1

func (c *Config) WithSnapshotThreshold(v uint64) *Config

WithSnapshotThreshold returns Config with SnapshotThreshold set to the given value.

func (*Config) WithTLS

func (c *Config) WithTLS(ca, cert, key []byte) *Config

WithTLS returns Config with TLS configuration set to the given values.

func (*Config) WithTLSFiles

func (c *Config) WithTLSFiles(caFile, certFile, keyFile string) *Config

WithTLSFiles returns Config with TLS configuration set to the given values.

func (*Config) WithTrailingLogs added in v0.1.1

func (c *Config) WithTrailingLogs(v uint64) *Config

WithTrailingLogs returns Config with TrailingLogs set to the given value.

type DB

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

DB is a DBadger node.

func Start

func Start(cfg *Config) (*DB, error)

Start creates and starts DB.

You must always call DB.Stop before terminating.

func (*DB) Addr

func (db *DB) Addr() Address

Addr returns DB address.

func (*DB) Delete

func (db *DB) Delete(ctx context.Context, key []byte) error

Delete removes a key.

func (*DB) DeleteAll

func (db *DB) DeleteAll(ctx context.Context) error

DeleteAll removes all keys.

func (*DB) DeleteMany

func (db *DB) DeleteMany(ctx context.Context, keys [][]byte) error

DeleteMany removes multiple keys.

func (*DB) DeleteManyString

func (db *DB) DeleteManyString(ctx context.Context, keys []string) error

DeleteManyString removes multiple keys.

func (*DB) DeletePrefix

func (db *DB) DeletePrefix(ctx context.Context, prefix []byte) error

DeletePrefix removes keys with the given prefix.

func (*DB) DeletePrefixString

func (db *DB) DeletePrefixString(ctx context.Context, prefix string) error

DeletePrefixString removes keys with the given prefix.

func (*DB) DeleteRange

func (db *DB) DeleteRange(ctx context.Context, min, max []byte) (keys [][]byte, _ error)

DeleteRange removes keys in range [min, max] and returns keys that has been removed.

func (*DB) DeleteRangeString

func (db *DB) DeleteRangeString(ctx context.Context, min, max string) (keys []string, _ error)

DeleteRangeString removes keys in range [min, max] and returns keys that has been removed.

func (*DB) DeleteString

func (db *DB) DeleteString(ctx context.Context, key string) error

DeleteString removes a key.

func (*DB) Get

func (db *DB) Get(ctx context.Context, key []byte, readPreference ReadPreference) ([]byte, error)

Get returns value corresponding to the given key.

func (*DB) GetMany

func (db *DB) GetMany(ctx context.Context, keys [][]byte, readPreference ReadPreference) (values [][]byte, _ error)

GetMany returns values corresponding to the given keys.

func (*DB) GetManyString

func (db *DB) GetManyString(ctx context.Context, keys []string, readPreference ReadPreference) (values []string, _ error)

GetManyString returns values corresponding to the given keys.

func (*DB) GetPrefix

func (db *DB) GetPrefix(ctx context.Context, prefix []byte, readPreference ReadPreference) (keys, values [][]byte, _ error)

GetPrefix returns values for the keys with the given prefix.

func (*DB) GetPrefixString

func (db *DB) GetPrefixString(ctx context.Context, prefix string, readPreference ReadPreference) (keys, values []string, _ error)

GetPrefixString returns values for the keys with the given prefix.

func (*DB) GetRange

func (db *DB) GetRange(ctx context.Context, min, max []byte, count uint64, readPreference ReadPreference) (keys, values [][]byte, _ error)

GetRange returns maximum of count values for the keys in range [min, max].

Both min and max can be nil.

func (*DB) GetRangeString

func (db *DB) GetRangeString(ctx context.Context, min, max string, count uint64, readPreference ReadPreference) (keys, values []string, _ error)

GetRangeString returns maximum of count values for the keys in range [min, max].

Both min and max can be nil.

func (*DB) GetString

func (db *DB) GetString(ctx context.Context, key string, readPreference ReadPreference) (string, error)

GetString returns value corresponding to the given key.

func (*DB) IsLeader

func (db *DB) IsLeader() bool

IsLeader returns whether node is a cluster leader.

func (*DB) IsReady

func (db *DB) IsReady() bool

IsReady returns whether node is ready to process commands.

func (*DB) Leader

func (db *DB) Leader() Address

Leader returns cluster leader's address.

func (*DB) Nodes

func (db *DB) Nodes() []Address

Nodes returns cluster nodes.

func (*DB) Restore

func (db *DB) Restore(id string) error

Restore forces DB to consume a snapshot, such as if restoring from a backup. This should not be used in normal operation, only for disaster recovery onto a new cluster.

func (*DB) Set

func (db *DB) Set(ctx context.Context, key, value []byte) error

Set adds a key-value pair.

func (*DB) SetMany

func (db *DB) SetMany(ctx context.Context, keys, values [][]byte) error

SetMany adds multiple key-value pairs.

func (*DB) SetManyString

func (db *DB) SetManyString(ctx context.Context, keys, values []string) error

SetManyString adds multiple key-value pairs.

func (*DB) SetString

func (db *DB) SetString(ctx context.Context, key, value string) error

SetString adds a key-value pair.

func (*DB) Snapshot

func (db *DB) Snapshot() (id string, err error)

Snapshot forces DB to take a snapshot, e.g. for backup purposes. Returns snapshot id and error, if any.

func (*DB) Stats

func (db *DB) Stats() map[string]string

Stats returns internal stats for debugging purposes.

func (*DB) Stop

func (db *DB) Stop() error

Stop stops DB.

type Logger

type Logger interface {
	Debugf(format string, args ...any)
	Infof(format string, args ...any)
	Warningf(format string, args ...any)
	Errorf(format string, args ...any)
	Fatalf(format string, args ...any)
}

type ReadPreference

type ReadPreference = rpc.ReadPreference

ReadPreference determines how DB routes read requests to the nodes of the cluster.

type StoreConfig added in v0.1.1

type StoreConfig struct {
	// SyncWrites controls whether Badger would call an additional msync after writes to flush mmap
	// buffer over to disk to survive hard reboots. Most users should not need to do this.
	SyncWrites bool

	// MaxLevels is the maximum number of levels of compaction allowed in the LSM.
	MaxLevels int
	// LevelSizeMultiplier sets the ratio between the maximum sizes of contiguous levels in the LSM.
	// Once a level grows to be larger than this ratio, the compaction process will be triggered.
	LevelSizeMultiplier int
	// BaseTableSize sets the maximum size in bytes for LSM table or file in the base level.
	BaseTableSize int64
	// BaseLevelSize sets the maximum size target for the base level.
	BaseLevelSize int64
	// ValueLogFileSize sets the maximum size of a single value log file.
	ValueLogFileSize int64
	// ValueLogMaxEntries sets the maximum number of entries a value log file can hold approximately.
	//
	// The actual size limit of a value log file is the
	// minimum of ValueLogFileSize and ValueLogMaxEntries.
	ValueLogMaxEntries uint32

	// NumMemtables sets the maximum number of tables to keep in memory before stalling.
	NumMemtables int
	// MemTableSize sets the maximum size in bytes for memtable table.
	MemTableSize int64

	// BlockSize sets the size of any block in SSTable. SSTable is divided into multiple blocks internally.
	BlockSize int
	// BlockCacheSize specifies how much data cache should be held in memory. A small size
	// of cache means lower memory consumption and lookups/iterations would take
	// longer. It is recommended to use a cache if you're using compression or encryption.
	// If compression and encryption both are disabled, adding a cache will lead to
	// unnecessary overhead which will affect the read performance. Setting size to
	// zero disables the cache altogether.
	BlockCacheSize int64

	// NumLevelZeroTables sets the maximum number of Level 0 tables before compaction starts.
	NumLevelZeroTables int
	// NumLevelZeroTablesStall sets the number of Level 0 tables that once reached causes the DB to
	// stall until compaction succeeds.
	NumLevelZeroTablesStall int
	// NumCompactors sets the number of compaction workers to run concurrently.  Setting this to
	// zero stops compactions, which could eventually cause writes to block forever.
	NumCompactors int
	// CompactL0OnClose sets whether Level 0 should be compacted before closing the DB. This ensures
	// that both reads and writes are efficient when the DB is opened later.
	CompactL0OnClose bool

	// Compression enables snappy compression for every block.
	Compression bool

	// GCEnabled enables value log garbage collection.
	GCEnabled bool
	// GCInterval sets value log garbage collection interval.
	GCInterval time.Duration
	// GCDiscardRatio sets threshold for rewriting files during garbage collection.
	//
	// During value log garbage collection Badger will rewrite files when it can discard
	// at least discardRatio space of that file.
	GCDiscardRatio float64
}

StoreConfig is a persistent storage configuration.

func DefaultDataStoreConfig added in v0.1.1

func DefaultDataStoreConfig() *StoreConfig

DefaultDataStoreConfig returns default data storage config.

func DefaultLogStoreConfig added in v0.1.1

func DefaultLogStoreConfig() *StoreConfig

DefaultLogStoreConfig returns default replicated log storage config.

func (*StoreConfig) WithBaseLevelSize added in v0.1.1

func (c *StoreConfig) WithBaseLevelSize(v int64) *StoreConfig

WithBaseLevelSize returns [StorageConfig] with BaseLevelSize set to the given value.

func (*StoreConfig) WithBaseTableSize added in v0.1.1

func (c *StoreConfig) WithBaseTableSize(v int64) *StoreConfig

WithBaseTableSize returns [StorageConfig] with BaseTableSize set to the given value.

func (*StoreConfig) WithBlockCacheSize added in v0.1.1

func (c *StoreConfig) WithBlockCacheSize(v int64) *StoreConfig

WithBlockCacheSize returns [StorageConfig] with BlockCacheSize set to the given value.

func (*StoreConfig) WithBlockSize added in v0.1.1

func (c *StoreConfig) WithBlockSize(v int) *StoreConfig

WithBlockSize returns [StorageConfig] with BlockSize set to the given value.

func (*StoreConfig) WithCompactL0OnClose added in v0.1.1

func (c *StoreConfig) WithCompactL0OnClose(v bool) *StoreConfig

WithCompactL0OnClose returns [StorageConfig] with CompactL0OnClose set to the given value.

func (*StoreConfig) WithCompression added in v0.1.1

func (c *StoreConfig) WithCompression(v bool) *StoreConfig

WithCompression returns [StorageConfig] with Compression set to the given value.

func (*StoreConfig) WithGC added in v0.1.1

func (c *StoreConfig) WithGC(interval time.Duration, discardRatio float64) *StoreConfig

WithGC returns [StorageConfig] with value log garbage collection enabled.

func (*StoreConfig) WithLevelSizeMultiplier added in v0.1.1

func (c *StoreConfig) WithLevelSizeMultiplier(v int) *StoreConfig

WithLevelSizeMultiplier returns [StorageConfig] with LevelSizeMultiplier set to the given value.

func (*StoreConfig) WithMaxLevels added in v0.1.1

func (c *StoreConfig) WithMaxLevels(v int) *StoreConfig

WithMaxLevels returns [StorageConfig] with MaxLevels set to the given value.

func (*StoreConfig) WithMemTableSize added in v0.1.1

func (c *StoreConfig) WithMemTableSize(v int64) *StoreConfig

WithMemTableSize returns [StorageConfig] with MemTableSize set to the given value.

func (*StoreConfig) WithNumCompactors added in v0.1.1

func (c *StoreConfig) WithNumCompactors(v int) *StoreConfig

WithNumCompactors returns [StorageConfig] with NumCompactors set to the given value.

func (*StoreConfig) WithNumLevelZeroTables added in v0.1.1

func (c *StoreConfig) WithNumLevelZeroTables(v int) *StoreConfig

WithNumLevelZeroTables returns [StorageConfig] with NumLevelZeroTables set to the given value.

func (*StoreConfig) WithNumLevelZeroTablesStall added in v0.1.1

func (c *StoreConfig) WithNumLevelZeroTablesStall(v int) *StoreConfig

WithNumLevelZeroTablesStall returns [StorageConfig] with NumLevelZeroTablesStall set to the given value.

func (*StoreConfig) WithNumMemtables added in v0.1.1

func (c *StoreConfig) WithNumMemtables(v int) *StoreConfig

WithNumMemtables returns [StorageConfig] with NumMemtables set to the given value.

func (*StoreConfig) WithSyncWrites added in v0.1.1

func (c *StoreConfig) WithSyncWrites(v bool) *StoreConfig

WithSyncWrites returns [StorageConfig] with SyncWrites set to the given value.

func (*StoreConfig) WithValueLogFileSize added in v0.1.1

func (c *StoreConfig) WithValueLogFileSize(v int64) *StoreConfig

WithValueLogFileSize returns [StorageConfig] with ValueLogFileSize set to the given value.

func (*StoreConfig) WithValueLogMaxEntries added in v0.1.1

func (c *StoreConfig) WithValueLogMaxEntries(v uint32) *StoreConfig

WithValueLogMaxEntries returns [StorageConfig] with ValueLogMaxEntries set to the given value.

type TLSConfig

type TLSConfig struct {
	CA   []byte // PEM encoded TLS certificate authority.
	Cert []byte // PEM encoded TLS certificate.
	Key  []byte // PEM encoded TLS private key.

	CAFile   string // TLS certificate authority file path.
	CertFile string // TLS certificate file path.
	KeyFile  string // TLS private key file path.
}

TLSConfig is a TLS configuration.

PEM encoded options are prioritized over file paths. You can mix both file and PEM options in the same config.

Directories

Path Synopsis
cmd
internal
mux
rpc

Jump to

Keyboard shortcuts

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