Back to godoc.org
github.com/coreos/etcd/mvcc/backend

package backend

v3.3.22+incompatible
Latest Go to latest
Published: May 20, 2020 | License: Apache-2.0 | Module: github.com/coreos/etcd

Overview

Package backend defines a standard interface for etcd's backend MVCC storage.

Index

func NewDefaultTmpBackend

func NewDefaultTmpBackend() (*backend, string)

func NewTmpBackend

func NewTmpBackend(batchInterval time.Duration, batchLimit int) (*backend, string)

NewTmpBackend creates a backend implementation for testing.

type Backend

type Backend interface {
	ReadTx() ReadTx
	BatchTx() BatchTx

	Snapshot() Snapshot
	Hash(ignores map[IgnoreKey]struct{}) (uint32, error)
	// Size returns the current size of the backend.
	Size() int64
	// SizeInUse returns the current size of the backend logically in use.
	// Since the backend can manage free space in a non-byte unit such as
	// number of pages, the returned value can be not exactly accurate in bytes.
	SizeInUse() int64
	Defrag() error
	ForceCommit()
	Close() error
}

func New

func New(bcfg BackendConfig) Backend

func NewDefaultBackend

func NewDefaultBackend(path string) Backend

type BackendConfig

type BackendConfig struct {
	// Path is the file path to the backend file.
	Path string
	// BatchInterval is the maximum time before flushing the BatchTx.
	BatchInterval time.Duration
	// BatchLimit is the maximum puts before flushing the BatchTx.
	BatchLimit int
	// MmapSize is the number of bytes to mmap for the backend.
	MmapSize uint64
}

func DefaultBackendConfig

func DefaultBackendConfig() BackendConfig

type BatchTx

type BatchTx interface {
	ReadTx
	UnsafeCreateBucket(name []byte)
	UnsafePut(bucketName []byte, key []byte, value []byte)
	UnsafeSeqPut(bucketName []byte, key []byte, value []byte)
	UnsafeDelete(bucketName []byte, key []byte)
	// Commit commits a previous tx and begins a new writable one.
	Commit()
	// CommitAndStop commits the previous tx and does not create a new one.
	CommitAndStop()
}

type IgnoreKey

type IgnoreKey struct {
	Bucket string
	Key    string
}

type ReadTx

type ReadTx interface {
	Lock()
	Unlock()

	UnsafeRange(bucketName []byte, key, endKey []byte, limit int64) (keys [][]byte, vals [][]byte)
	UnsafeForEach(bucketName []byte, visitor func(k, v []byte) error) error
}

type Snapshot

type Snapshot interface {
	// Size gets the size of the snapshot.
	Size() int64
	// WriteTo writes the snapshot into the given writer.
	WriteTo(w io.Writer) (n int64, err error)
	// Close closes the snapshot.
	Close() error
}
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier