repository

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

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)
	OnSegmentStored(identifier string)
	OnSegmentDeleted(identifier string)
}

Callback provides events when repository data being modified

type FFRepository added in v0.0.25

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

FFRepository holds cache and optionally offline data

func (FFRepository) Close added in v0.0.25

func (r FFRepository) Close()

Close all resources

func (FFRepository) DeleteFlag added in v0.0.25

func (r FFRepository) DeleteFlag(identifier string)

DeleteFlag removes a flag from the repository

func (FFRepository) DeleteSegment added in v0.0.25

func (r FFRepository) DeleteSegment(identifier string)

DeleteSegment removes a segment from the repository

func (FFRepository) GetFlag added in v0.0.25

func (r FFRepository) GetFlag(identifier string) (rest.FeatureConfig, error)

GetFlag returns flag from cache or offline storage

func (FFRepository) GetFlags added in v0.1.5

func (r FFRepository) GetFlags() ([]rest.FeatureConfig, error)

GetFlags returns all the flags /* Not implemented */

func (FFRepository) GetSegment added in v0.0.25

func (r FFRepository) GetSegment(identifier string) (rest.Segment, error)

GetSegment returns flag from cache or offline storage

func (FFRepository) SetFlag added in v0.0.25

func (r FFRepository) SetFlag(featureConfig rest.FeatureConfig, initialLoad bool)

SetFlag places a flag in the repository with the new value

func (FFRepository) SetSegment added in v0.0.25

func (r FFRepository) SetSegment(segment rest.Segment, initialLoad bool)

SetSegment places a segment in the repository with the new value

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 Repository

type Repository interface {
	GetFlag(identifier string) (rest.FeatureConfig, error)
	GetSegment(identifier string) (rest.Segment, error)
	GetFlags() ([]rest.FeatureConfig, error)

	SetFlag(featureConfig rest.FeatureConfig, initialLoad bool)
	SetSegment(segment rest.Segment, initialLoad bool)

	DeleteFlag(identifier string)
	DeleteSegment(identifier string)

	Close()
}

Repository interface for data providers

func New

func New(cache Cache) Repository

New repository with only cache capabillity

func NewWithStorage

func NewWithStorage(cache Cache, storage storage.Storage) Repository

NewWithStorage works with offline storage implementation

func NewWithStorageAndCallback

func NewWithStorageAndCallback(cache Cache, storage storage.Storage, callback Callback) Repository

NewWithStorageAndCallback factory function with cache, offline storage and listener on events

Jump to

Keyboard shortcuts

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