state

package
v0.0.0-...-acc7c72 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidArgument = errors.New("ErrorInvalidArgument")

ErrInvalidArgument is returned when the argument type does not match the expected type

View Source
var ErrNotFound = errors.New("ErrorNotFound")

ErrNotFound is returned when no results are returned from the database

Functions

This section is empty.

Types

type DBStore

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

DBStore uses LevelDB to store values.

func NewDBStore

func NewDBStore(path string) (s *DBStore, err error)

NewDBStore creates a new instance of DBStore.

func (*DBStore) Close

func (s *DBStore) Close() error

Close releases the resources used by the underlying LevelDB.

func (*DBStore) Delete

func (s *DBStore) Delete(key string) (err error)

Delete removes entries stored under a specific key.

func (*DBStore) Get

func (s *DBStore) Get(key string, i interface{}) (err error)

Get retrieves a persisted value for a specific key. If there is no results ErrNotFound is returned. The provided parameter should be either a byte slice or a struct that implements the encoding.BinaryUnmarshaler interface

func (*DBStore) Put

func (s *DBStore) Put(key string, i interface{}) (err error)

Put stores an object that implements Binary for a specific key.

type InmemoryStore

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

InmemoryStore is the reference implementation of Store interface that is supposed to be used in tests.

func NewInmemoryStore

func NewInmemoryStore() *InmemoryStore

NewInmemoryStore returns a new instance of InmemoryStore.

func (*InmemoryStore) Close

func (s *InmemoryStore) Close() error

Close does not do anything.

func (*InmemoryStore) Delete

func (s *InmemoryStore) Delete(key string) (err error)

Delete removes value stored under a specific key.

func (*InmemoryStore) Get

func (s *InmemoryStore) Get(key string, i interface{}) (err error)

Get retrieves a value stored for a specific key. If there is no value found, ErrNotFound is returned.

func (*InmemoryStore) Put

func (s *InmemoryStore) Put(key string, i interface{}) (err error)

Put stores a value for a specific key.

type Store

type Store interface {
	Get(key string, i interface{}) (err error)
	Put(key string, i interface{}) (err error)
	Delete(key string) (err error)
	Close() error
}

Store defines methods required to get, set, delete values for different keys and close the underlying resources.

Jump to

Keyboard shortcuts

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