store

package
v0.0.0-...-7de36fb Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EtcdIterator

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

EtcdIterator is an iterator for etcdstore.

func (*EtcdIterator) GetNext

func (i *EtcdIterator) GetNext() (string, error)

GetNext gets the next element.

func (*EtcdIterator) HasNext

func (i *EtcdIterator) HasNext() bool

HasNext returns true if there are elements left to get with GetNext().

type EtcdStore

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

EtcdStore is a store that uses etcd as a backend.

func NewEtcdStore

func NewEtcdStore(endpoints []string, logger *zap.Logger, caCert, cert, key []byte) (*EtcdStore, error)

NewEtcdStore creates a new EtcdStore.

func (*EtcdStore) BeginTransaction

func (s *EtcdStore) BeginTransaction() (Transaction, error)

BeginTransaction starts a new transaction.

func (*EtcdStore) Close

func (s *EtcdStore) Close() error

Close closes the etcd client.

func (*EtcdStore) Delete

func (s *EtcdStore) Delete(key string) error

Delete deletes the store entry with the given key.

func (*EtcdStore) Get

func (s *EtcdStore) Get(request string) ([]byte, error)

Get retrieves a value from EtcdStore by Type and Name.

func (*EtcdStore) Iterator

func (s *EtcdStore) Iterator(prefix string) (Iterator, error)

Iterator returns an Iterator for a given prefix.

func (*EtcdStore) Put

func (s *EtcdStore) Put(request string, requestData []byte) error

Put saves a value in EtcdStore by Type and Name.

func (*EtcdStore) Transfer

func (s *EtcdStore) Transfer(_ Store) error

Transfer transfers all entries from this store to the given store. TODO: Implement this function, currently this function is never called.

type EtcdStoreFactory

type EtcdStoreFactory struct {
	Endpoint string
	ForceTLS bool

	Logger *zap.Logger
	// contains filtered or unexported fields
}

EtcdStoreFactory is a factory to create EtcdStores.

func (*EtcdStoreFactory) New

func (f *EtcdStoreFactory) New() (Store, error)

New creates a new EtcdStore.

type EtcdTransaction

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

EtcdTransaction is a transaction that uses etcd as a backend.

func (*EtcdTransaction) Commit

func (t *EtcdTransaction) Commit() error

Commit ends a transaction and persists the changes.

func (*EtcdTransaction) Delete

func (t *EtcdTransaction) Delete(key string) error

Delete deletes the key if it exists. Only errors if there is no ongoing Transaction.

func (*EtcdTransaction) Get

func (t *EtcdTransaction) Get(request string) ([]byte, error)

Get retrieves a value from EtcdTransaction by Name.

func (*EtcdTransaction) Iterator

func (t *EtcdTransaction) Iterator(prefix string) (Iterator, error)

Iterator returns an iterator for all keys in the transaction with a given prefix.

func (*EtcdTransaction) Put

func (t *EtcdTransaction) Put(request string, requestData []byte) error

Put saves a value.

func (*EtcdTransaction) Rollback

func (t *EtcdTransaction) Rollback()

Rollback aborts a transaction.

type Iterator

type Iterator interface {
	// GetNext returns the next element of the iterator.
	GetNext() (string, error)
	// HasNext returns true if there are elements left to get with GetNext().
	HasNext() bool
}

Iterator is an iterator for the store.

type StdIterator

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

StdIterator is the standard Iterator implementation.

func (*StdIterator) GetNext

func (i *StdIterator) GetNext() (string, error)

GetNext returns the next element of the iterator.

func (*StdIterator) HasNext

func (i *StdIterator) HasNext() bool

HasNext returns true if there are elements left to get with GetNext().

type StdStore

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

StdStore is the standard implementation of the Store interface.

func NewStdStore

func NewStdStore() *StdStore

NewStdStore creates and initializes a new StdStore object.

func (*StdStore) BeginTransaction

func (s *StdStore) BeginTransaction() (Transaction, error)

BeginTransaction starts a new transaction.

func (*StdStore) Delete

func (s *StdStore) Delete(key string) error

Delete deletes one element from the store.

func (*StdStore) Get

func (s *StdStore) Get(request string) ([]byte, error)

Get retrieves a value from StdStore by Type and Name.

func (*StdStore) Iterator

func (s *StdStore) Iterator(prefix string) (Iterator, error)

Iterator returns an iterator for keys saved in StdStore with a given prefix. For an empty prefix this is an iterator for all keys in StdStore.

func (*StdStore) Put

func (s *StdStore) Put(request string, requestData []byte) error

Put saves a value in StdStore by Type and Name.

func (*StdStore) Transfer

func (s *StdStore) Transfer(newstore Store) error

Transfer transfers the store content to another store.

type Store

type Store interface {
	// BeginTransaction starts a new transaction.
	BeginTransaction() (Transaction, error)
	// Get returns a value from store by key.
	Get(string) ([]byte, error)
	// Put saves a value to store by key.
	Put(string, []byte) error
	// Iterator returns an Iterator for a given prefix.
	Iterator(string) (Iterator, error)
	// Transfer copies the whole store Database.
	Transfer(Store) error
	// Delete deletes the key.
	Delete(string) error
}

Store is the interface for persistent store. Currently two backends are supported, stdstore (mainly for testing) and etcd for production.

type Transaction

type Transaction interface {
	// Get returns a value from store by key.
	Get(string) ([]byte, error)
	// Put saves a value to store by key.
	Put(string, []byte) error
	// Delete deletes the key.
	Delete(string) error
	// Iterator returns an Iterator for a given prefix.
	Iterator(string) (Iterator, error)
	// Commit ends a transaction and persists the changes.
	Commit() error
	// Rollback aborts a transaction. Noop if already committed.
	Rollback()
}

Transaction is a Store transaction.

type ValueUnsetError

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

ValueUnsetError is an error raised by unset values in the store.

func (*ValueUnsetError) Error

func (s *ValueUnsetError) Error() string

Error implements the Error interface.

Jump to

Keyboard shortcuts

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