ldbutils

package
v0.0.0-...-66acf6f Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: BSD-3-Clause, BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Metered specified that this DB should be metered.
	Metered = true
	// Unmetered specified that this DB should not be metered.
	Unmetered = false
)

Variables

This section is empty.

Functions

func GetVersionedPathForDb

func GetVersionedPathForDb(
	log logger.Logger, dirPath string, dbName string,
	currentDbVersion uint64) (versionedDirPath string, err error)

GetVersionedPathForDb returns a path for the db that includes a version number.

func LeveldbOptions

func LeveldbOptions(sizeGetter DbWriteBufferSizeGetter) *opt.Options

LeveldbOptions returns leveldb options.

Types

type CountMeter

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

CountMeter counts ticks with a sliding window into the past.

func NewCountMeter

func NewCountMeter() *CountMeter

NewCountMeter returns a new CountMeter.

func (*CountMeter) Count

func (m *CountMeter) Count() int64

Count returns the overall count.

func (*CountMeter) Mark

func (m *CountMeter) Mark(i int64)

Mark ticks the counters.

func (*CountMeter) Rate1

func (m *CountMeter) Rate1() float64

Rate1 returns the number of ticks in the last 1 minute.

func (*CountMeter) Rate15

func (m *CountMeter) Rate15() float64

Rate15 returns the number of ticks in the last 15 minutes.

func (*CountMeter) Rate5

func (m *CountMeter) Rate5() float64

Rate5 returns the number of ticks in the last 5 minutes.

func (*CountMeter) RateMean

func (m *CountMeter) RateMean() float64

RateMean returns the overall count of ticks.

func (*CountMeter) Shutdown

func (m *CountMeter) Shutdown() <-chan struct{}

Shutdown shuts down this CountMeter.

func (*CountMeter) Snapshot

func (m *CountMeter) Snapshot() metrics.Meter

Snapshot returns the snapshot in time of this CountMeter.

type DbWriteBufferSizeGetter

type DbWriteBufferSizeGetter interface {
	// DbWriteBufferSize indicates how large the write buffer should
	// be on local levelDbs -- this also controls how big the on-disk
	// tables are before compaction.
	DbWriteBufferSize() int
}

DbWriteBufferSizeGetter is an interface that contains a method for getting the size of a leveldb write buffer.

type LevelDb

type LevelDb struct {
	*leveldb.DB
	// contains filtered or unexported fields
}

LevelDb is a libkbfs wrapper for leveldb.DB.

func OpenLevelDb

func OpenLevelDb(
	stor storage.Storage, sizeGetter DbWriteBufferSizeGetter) (
	*LevelDb, error)

OpenLevelDb opens or recovers a leveldb.DB with a passed-in storage.Storage as its underlying storage layer.

func OpenLevelDbWithOptions

func OpenLevelDbWithOptions(stor storage.Storage, options *opt.Options) (
	*LevelDb, error)

OpenLevelDbWithOptions opens or recovers a leveldb.DB with a passed-in storage.Storage as its underlying storage layer, and with the options specified.

func OpenVersionedLevelDb

func OpenVersionedLevelDb(
	log logger.Logger, storageRoot string, dbFolderName string,
	currentDbVersion uint64, dbFilename string,
	sizeGetter DbWriteBufferSizeGetter) (db *LevelDb, err error)

OpenVersionedLevelDb opens a level DB under a versioned path on the local filesystem under storageRoot. The path include dbFolderName and dbFilename. Note that dbFilename is actually created as a folder; it's just where raw LevelDb lives.

func (*LevelDb) Close

func (ldb *LevelDb) Close() (err error)

Close closes the DB.

func (*LevelDb) Get

func (ldb *LevelDb) Get(key []byte, ro *opt.ReadOptions) (
	value []byte, err error)

Get gets data from the DB.

func (*LevelDb) GetWithMeter

func (ldb *LevelDb) GetWithMeter(key []byte, hitMeter, missMeter *CountMeter) (
	value []byte, err error)

GetWithMeter gets data from the DB while tracking the hit rate.

func (*LevelDb) Put

func (ldb *LevelDb) Put(key, value []byte, wo *opt.WriteOptions) (err error)

Put puts data into the DB.

func (*LevelDb) PutWithMeter

func (ldb *LevelDb) PutWithMeter(key, value []byte, putMeter *CountMeter) (
	err error)

PutWithMeter gets data from the DB while tracking the hit rate.

func (*LevelDb) StatStrings

func (ldb *LevelDb) StatStrings() ([]string, error)

StatStrings returns newline-split leveldb stats, suitable for JSONification.

type MeterSnapshot

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

MeterSnapshot is a read-only copy of another Meter.

func (*MeterSnapshot) Count

func (m *MeterSnapshot) Count() int64

Count returns the count of events at the time the snapshot was taken.

func (*MeterSnapshot) Mark

func (*MeterSnapshot) Mark(n int64)

Mark panics.

func (*MeterSnapshot) Rate1

func (m *MeterSnapshot) Rate1() float64

Rate1 returns the one-minute moving average rate of events per second at the time the snapshot was taken.

func (*MeterSnapshot) Rate15

func (m *MeterSnapshot) Rate15() float64

Rate15 returns the fifteen-minute moving average rate of events per second at the time the snapshot was taken.

func (*MeterSnapshot) Rate5

func (m *MeterSnapshot) Rate5() float64

Rate5 returns the five-minute moving average rate of events per second at the time the snapshot was taken.

func (*MeterSnapshot) RateMean

func (m *MeterSnapshot) RateMean() float64

RateMean returns the meter's mean rate of events per second at the time the snapshot was taken.

func (*MeterSnapshot) Snapshot

func (m *MeterSnapshot) Snapshot() metrics.Meter

Snapshot returns the snapshot.

type MeterStatus

type MeterStatus struct {
	Minutes1  float64
	Minutes5  float64
	Minutes15 float64
	Count     int64
}

MeterStatus represents the status of a rate meter.

func RateMeterToStatus

func RateMeterToStatus(m metrics.Meter) MeterStatus

RateMeterToStatus returns the status for a meter.

Jump to

Keyboard shortcuts

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