storage

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHarnessDir

func GetHarnessDir(logger logger.Logger) string

GetHarnessDir returns home folder for harness ff server files

Types

type FileStore

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

FileStore object is simple JSON file representation

func NewFileStore

func NewFileStore(project string, path string, logger logger.Logger) *FileStore

NewFileStore creates a new file store instance

func (*FileStore) Get

func (ds *FileStore) Get(key string) (interface{}, bool)

Get value with the specified key

func (*FileStore) List

func (ds *FileStore) List() []interface{}

List all values

func (*FileStore) Load

func (ds *FileStore) Load() error

Load data from the store

func (*FileStore) Persist

func (ds *FileStore) Persist() error

Persist data to the store

func (*FileStore) PersistedAt

func (ds *FileStore) PersistedAt() time.Time

PersistedAt returns when it was last recorded

func (*FileStore) Remove added in v0.0.24

func (ds *FileStore) Remove(key string) error

Remove object from data store identified by key parameter

func (*FileStore) Reset

func (ds *FileStore) Reset(data map[string]interface{}, persist bool) error

Reset data with custom value, if persist is true save it to the store

func (*FileStore) Set

func (ds *FileStore) Set(key string, value interface{}) error

Set new key and value

func (*FileStore) SetLogger

func (ds *FileStore) SetLogger(logger logger.Logger)

SetLogger set logger

type Storage

type Storage interface {

	// Reset is called after the repository has fetched the feature toggles from the server.
	// If persist is true the implementation of this function should call Persist(). The data
	// passed in here should be owned by the implementer of this interface.
	Reset(data map[string]interface{}, persist bool) error

	// Load is called to load the data from persistent storage and hold it in memory for fast
	// querying.
	Load() error

	// Persist is called when the data in the storage implementation should be persisted to disk.
	Persist() error

	// Get returns the data for the specified feature toggle.
	Get(string) (interface{}, bool)

	Set(string, interface{}) error

	Remove(string) error

	// List returns a list of all feature toggles.
	List() []interface{}

	PersistedAt() time.Time

	SetLogger(logger logger.Logger)
}

Storage is an interface that can be implemented in order to have control over how the repository of feature toggles is persisted.

Jump to

Keyboard shortcuts

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