inmem

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PutDisabledError    = errors.New("put operations disabled in inmem backend")
	GetDisabledError    = errors.New("get operations disabled in inmem backend")
	DeleteDisabledError = errors.New("delete operations disabled in inmem backend")
	ListDisabledError   = errors.New("list operations disabled in inmem backend")
)

Functions

func NewInmem

func NewInmem(_ map[string]string, logger log.Logger) (physical.Backend, error)

NewInmem constructs a new in-memory backend

func NewInmemHA

func NewInmemHA(_ map[string]string, logger log.Logger) (physical.Backend, error)

NewInmemHA constructs a new in-memory HA backend. This is only for testing.

func NewTransactionalInmem

func NewTransactionalInmem(_ map[string]string, logger log.Logger) (physical.Backend, error)

Basically for now just creates a permit pool of size 1 so only one operation can run at a time

func NewTransactionalInmemHA

func NewTransactionalInmemHA(_ map[string]string, logger log.Logger) (physical.Backend, error)

Types

type IBackend

type IBackend struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

InmemBackend is an in-memory only physical backend. It is useful for testing and development situations where the data is not expected to be durable.

func (*IBackend) Delete

func (i *IBackend) Delete(ctx context.Context, key string) error

Delete is used to permanently delete an entry

func (*IBackend) DeleteInternal

func (i *IBackend) DeleteInternal(ctx context.Context, key string) error

func (*IBackend) FailDelete

func (i *IBackend) FailDelete(fail bool)

func (*IBackend) FailGet

func (i *IBackend) FailGet(fail bool)

func (*IBackend) FailList

func (i *IBackend) FailList(fail bool)

func (*IBackend) FailPut

func (i *IBackend) FailPut(fail bool)

func (*IBackend) Get

func (i *IBackend) Get(ctx context.Context, key string) (*physical.Entry, error)

Get is used to fetch an entry

func (*IBackend) GetInternal

func (i *IBackend) GetInternal(ctx context.Context, key string) (*physical.Entry, error)

func (*IBackend) List

func (i *IBackend) List(ctx context.Context, prefix string) ([]string, error)

List is used to list all the keys under a given prefix, up to the next prefix.

func (*IBackend) ListInternal

func (i *IBackend) ListInternal(ctx context.Context, prefix string) ([]string, error)

func (*IBackend) Put

func (i *IBackend) Put(ctx context.Context, entry *physical.Entry) error

Put is used to insert or update an entry

func (*IBackend) PutInternal

func (i *IBackend) PutInternal(ctx context.Context, entry *physical.Entry) error

type IHABackend

type IHABackend struct {
	physical.Backend
	// contains filtered or unexported fields
}

func (*IHABackend) HAEnabled

func (i *IHABackend) HAEnabled() bool

HAEnabled indicates whether the HA functionality should be exposed. Currently always returns true.

func (*IHABackend) LockMapSize

func (i *IHABackend) LockMapSize() int

LockMapSize is used in some tests to determine whether this backend has ever been used for HA purposes rather than simply for storage

func (*IHABackend) LockWith

func (i *IHABackend) LockWith(key, value string) (physical.Lock, error)

LockWith is used for mutual exclusion based on the given key.

type ILock

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

InmemLock is an in-memory Lock implementation for the HABackend

func (*ILock) Lock

func (i *ILock) Lock(stopCh <-chan struct{}) (<-chan struct{}, error)

func (*ILock) Unlock

func (i *ILock) Unlock() error

func (*ILock) Value

func (i *ILock) Value() (bool, string, error)

type TransactionalInmemBackend

type TransactionalInmemBackend struct {
	IBackend
}

func (*TransactionalInmemBackend) Transaction

func (t *TransactionalInmemBackend) Transaction(ctx context.Context, txns []*physical.TxnEntry) error

Implements the transaction interface

type TransactionalInmemHABackend

type TransactionalInmemHABackend struct {
	physical.Transactional
	IHABackend
}

Jump to

Keyboard shortcuts

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