repository

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 7 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)
	OnFlagsStored(envID string)
	OnFlagsDeleted(envID string, identifier string)
	OnFlagDeleted(identifier string)
	OnSegmentStored(identifier string)
	OnSegmentsStored(envID string)
	OnSegmentDeleted(identifier string)
	OnSegmentsDeleted(envID string, 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) DeleteFlags added in v0.1.11

func (r FFRepository) DeleteFlags(envID string, identifier string)

DeleteFlags removes a flag from the flags key.

We can't just delete the key here the way we can for a single flag because then we'd be removing flags that haven't been deleted. So we have to first fetch value, then remove the specific flag that has been deleted and update the key in the cache/storage

func (FFRepository) DeleteSegment added in v0.0.25

func (r FFRepository) DeleteSegment(identifier string)

DeleteSegment removes a segment from the repository

func (FFRepository) DeleteSegments added in v0.1.11

func (r FFRepository) DeleteSegments(envID string, identifier string)

DeleteSegments removes a Segment from the segments key.

We can't just delete the key here the way we can for a single flag because then we'd be removing segments that haven't been deleted. So we have to first fetch value, then remove the specific segment that has been deleted and update the key in the cache/storage

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) GetFlagMap added in v0.1.11

func (r FFRepository) GetFlagMap() (map[string]*rest.FeatureConfig, error)

GetFlagMap returns all flags as a mao /* Not Implemented *.

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) SetFlags added in v0.1.9

func (r FFRepository) SetFlags(initialLoad bool, envID string, featureConfigs ...rest.FeatureConfig)

SetFlags places all the flags in the repository

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

func (FFRepository) SetSegments added in v0.1.9

func (r FFRepository) SetSegments(initialLoad bool, envID string, segments ...rest.Segment)

SetSegments places all the segments in the repository

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)
	GetFlagMap() (map[string]*rest.FeatureConfig, error)

	SetFlag(featureConfig rest.FeatureConfig, initialLoad bool)
	SetFlags(initialLoad bool, envID string, featureConfig ...rest.FeatureConfig)
	SetSegment(segment rest.Segment, initialLoad bool)
	SetSegments(initialLoad bool, envID string, segment ...rest.Segment)

	DeleteFlag(identifier string)
	DeleteFlags(envID string, identifier string)
	DeleteSegment(identifier string)
	DeleteSegments(envID string, 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