database

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNothingToCleanUp is returned when nothing is there to clean up in the database.
	ErrNothingToCleanUp = errors.New("Nothing to clean up in the databases")
)

Functions

func DatabaseCleanupCaller added in v1.0.5

func DatabaseCleanupCaller(handler interface{}, params ...interface{})

func DatabaseExists added in v1.1.0

func DatabaseExists(dbPath string) (bool, error)

DatabaseExists checks if the database folder exists and is not empty.

func NewPebbleDB

func NewPebbleDB(directory string, reportCompactionRunning func(running bool), enableFilter bool) (*pebbleDB.DB, error)

NewPebbleDB creates a new pebble DB instance.

func NewRocksDB

func NewRocksDB(path string) (*rocksdb.RocksDB, error)

NewRocksDB creates a new RocksDB instance.

func StoreWithDefaultSettings added in v1.0.5

func StoreWithDefaultSettings(path string, createDatabaseIfNotExists bool, dbEngine ...Engine) (kvstore.KVStore, error)

StoreWithDefaultSettings returns a kvstore with default settings. It also checks if the database engine is correct.

Types

type Database

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

Database holds the underlying KVStore and database specific functions.

func New

func New(databaseDirectory string, kvStore kvstore.KVStore, engine Engine, metrics *metrics.DatabaseMetrics, events *Events, compactionSupported bool, compactionRunningFunc func() bool) *Database

New creates a new Database instance.

func (*Database) CompactionRunning

func (db *Database) CompactionRunning() bool

CompactionRunning returns whether a compaction is running.

func (*Database) CompactionSupported added in v1.0.2

func (db *Database) CompactionSupported() bool

CompactionSupported returns whether the database engine supports compaction.

func (*Database) Engine added in v1.2.0

func (db *Database) Engine() Engine

Engine returns the database engine.

func (*Database) Events added in v1.0.5

func (db *Database) Events() *Events

Events returns the events of the database.

func (*Database) KVStore

func (db *Database) KVStore() kvstore.KVStore

KVStore returns the underlying KVStore.

func (*Database) Metrics added in v1.2.0

func (db *Database) Metrics() *metrics.DatabaseMetrics

Metrics returns the database metrics.

func (*Database) Size added in v1.1.0

func (db *Database) Size() (int64, error)

Size returns the size of the database.

type DatabaseCleanup added in v1.0.5

type DatabaseCleanup struct {
	Start time.Time
	End   time.Time
}

func (*DatabaseCleanup) MarshalJSON added in v1.0.5

func (c *DatabaseCleanup) MarshalJSON() ([]byte, error)

type Engine added in v1.0.5

type Engine string
const (
	EngineUnknown Engine = "unknown"
	EngineAuto    Engine = "auto"
	EngineRocksDB Engine = "rocksdb"
	EnginePebble  Engine = "pebble"
	EngineMapDB   Engine = "mapdb"
)

func CheckDatabaseEngine added in v1.0.5

func CheckDatabaseEngine(dbPath string, createDatabaseIfNotExists bool, dbEngine ...Engine) (Engine, error)

CheckDatabaseEngine checks if the correct database engine is used. This function stores a so called "database info file" in the database folder or checks if an existing "database info file" contains the correct engine. Otherwise the files in the database folder are not compatible.

func DatabaseEngineAllowed added in v1.2.0

func DatabaseEngineAllowed(dbEngine Engine, allowedEngines ...Engine) (Engine, error)

DatabaseEngineAllowed checks if the database engine is allowed.

func DatabaseEngineFromString added in v1.2.0

func DatabaseEngineFromString(engineStr string) (Engine, error)

DatabaseEngineFromString parses an engine from a string. Returns an error if the engine is unknown.

func DatabaseEngineFromStringAllowed added in v1.2.0

func DatabaseEngineFromStringAllowed(dbEngineStr string, allowedEngines ...Engine) (Engine, error)

DatabaseEngineFromStringAllowed parses an engine from a string and checks if the database engine is allowed.

func LoadDatabaseEngineFromFile added in v1.0.5

func LoadDatabaseEngineFromFile(path string) (Engine, error)

LoadDatabaseEngineFromFile returns the engine from the "database info file".

type Events added in v1.0.5

type Events struct {
	DatabaseCleanup    *events.Event
	DatabaseCompaction *events.Event
}

Jump to

Keyboard shortcuts

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