etcd: Index | Files

package backend

import ""

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


Package Files

backend.go batch_tx.go config_linux.go doc.go metrics.go read_tx.go tx_buffer.go

func NewDefaultTmpBackend Uses

func NewDefaultTmpBackend() (*backend, string)

func NewTmpBackend Uses

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

NewTmpBackend creates a backend implementation for testing.

type Backend Uses

type Backend interface {
    // ReadTx returns a read transaction. It is replaced by ConcurrentReadTx in the main data path, see #10523.
    ReadTx() ReadTx
    BatchTx() BatchTx
    // ConcurrentReadTx returns a non-blocking read transaction.
    ConcurrentReadTx() ReadTx

    Snapshot() Snapshot
    Hash(ignores map[IgnoreKey]struct{}) (uint32, error)
    // Size returns the current size of the backend physically allocated.
    // The backend can hold DB space that is not utilized at the moment,
    // since it can conduct pre-allocation or spare unused space for recycling.
    // Use SizeInUse() instead for the actual DB size.
    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
    // OpenReadTxN returns the number of currently open read transactions in the backend.
    OpenReadTxN() int64
    Defrag() error
    Close() error

func New Uses

func New(bcfg BackendConfig) Backend

func NewDefaultBackend Uses

func NewDefaultBackend(path string) Backend

type BackendConfig Uses

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
    // BackendFreelistType is the backend boltdb's freelist type.
    BackendFreelistType bolt.FreelistType
    // MmapSize is the number of bytes to mmap for the backend.
    MmapSize uint64
    // Logger logs backend-side operations.
    Logger *zap.Logger
    // UnsafeNoFsync disables all uses of fsync.
    UnsafeNoFsync bool `json:"unsafe-no-fsync"`

func DefaultBackendConfig Uses

func DefaultBackendConfig() BackendConfig

type BatchTx Uses

type BatchTx interface {
    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.
    // CommitAndStop commits the previous tx and does not create a new one.

type IgnoreKey Uses

type IgnoreKey struct {
    Bucket string
    Key    string

type ReadTx Uses

type ReadTx interface {

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

type Snapshot Uses

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

Package backend imports 17 packages (graph) and is imported by 236 packages. Updated 2020-07-06. Refresh now. Tools for package owners.