repository

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2022 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFeatureConfigNotFound ...
	ErrFeatureConfigNotFound = errors.New("feature config not found")
	// ErrSegmentNotFound ...
	ErrSegmentNotFound = errors.New("target group not found")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Set(key interface{}, value interface{}) (evicted bool)
	Contains(key interface{}) bool
	Get(key interface{}) (value interface{}, ok bool)
	Keys() []interface{}
	Len() int
	Remove(key interface{}) (present bool)
}

Cache wrapper to integrate any 3rd party implementation

type Callback

type Callback interface {
	OnFlagStored(identifier string)
	OnFlagDeleted(identifier string)
	OnVariableStored(identifier string)
	OnVariableDeleted(identifier string)
}

Callback provides events when repository data being modified

type FileStorage

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

func NewFileStorage

func NewFileStorage(path string) (FileStorage, error)

func (*FileStorage) Get

func (f *FileStorage) Get(key string, output interface{}) error

func (*FileStorage) List

func (f *FileStorage) List() []interface{}

func (*FileStorage) Remove

func (f *FileStorage) Remove(s string) error

func (*FileStorage) Set

func (f *FileStorage) Set(key string, value interface{}) error

type LRUCache

type LRUCache struct {
	*lru.Cache
}

LRUCache is thread-safe LAST READ USED Cache

func NewLruCache

func NewLruCache(size int) (LRUCache, error)

NewLruCache creates a new LRU instance

func (LRUCache) Contains

func (lru LRUCache) Contains(key interface{}) bool

Contains checks if a key is in the cache

func (LRUCache) Get

func (lru LRUCache) Get(key interface{}) (value interface{}, ok bool)

Get looks up a key's value from the cache.

func (LRUCache) Keys

func (lru LRUCache) Keys() []interface{}

Keys returns a slice of the keys in the cache, from oldest to newest.

func (LRUCache) Len

func (lru LRUCache) Len() int

Len returns the number of items in the cache.

func (LRUCache) Remove

func (lru LRUCache) Remove(key interface{}) (present bool)

Remove removes the provided key from the cache.

func (LRUCache) Set

func (lru LRUCache) Set(key interface{}, value interface{}) (evicted bool)

Set a new value if it is different from the previous one. Returns true if an eviction occurred.

type Option

type Option func(r *Repository)

func WithCallback

func WithCallback(callback Callback) Option

func WithStorage

func WithStorage(storage Storage) Option

type Repository

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

Repository holds cache and optionally offline data

func New

func New(cache Cache, options ...Option) Repository

New repository with only cache capability

func (Repository) Close

func (r Repository) Close()

Close all resources

func (Repository) DeleteConfiguration

func (r Repository) DeleteConfiguration(identifier string)

DeleteConfiguration removes a flag from the repository

func (Repository) DeleteVariable

func (r Repository) DeleteVariable(identifier string)

DeleteVariable removes a segment from the repository

func (Repository) GetConfiguration

func (r Repository) GetConfiguration(identifier string) (evaluation.Configuration, error)

GetConfiguration returns flag from cache or offline storage

func (Repository) GetVariable

func (r Repository) GetVariable(identifier string) (evaluation.Variable, error)

GetVariable return variable from repository

func (Repository) SetConfiguration

func (r Repository) SetConfiguration(config *evaluation.Configuration)

SetConfiguration places a flag in the repository with the new value

func (Repository) SetVariable

func (r Repository) SetVariable(variable *evaluation.Variable)

SetVariable places a variable in the repository with the new value

type Storage

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

	Set(string, interface{}) error

	Remove(string) error

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

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