Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache interface {
// Copy return a copy version of the cache.
Copy() Cache
// All return the complete list of the flags, as deep copies the caller is free to change.
All() map[string]flag.Flag
// Init allow to initialize the cache with a collection of flags.
Init(flags map[string]dto.DTO)
// contains filtered or unexported methods
}
Cache is the interface to represent a cache in the system.
type InMemoryCache ¶
type InMemoryCache struct {
// Flags are the flags by key. A flag of the map is shared by every reader: it must be treated
// as read-only once it is in the map.
Flags map[string]*flag.InternalFlag
Logger *fflog.FFLogger
// Service validates the flags that are added, and keeps the parses of their queries.
Service *flag.Service
}
func NewInMemoryCache ¶
func NewInMemoryCache(svc *flag.Service, logger *fflog.FFLogger) *InMemoryCache
NewInMemoryCache creates an empty cache, which validates its flags with svc.
func (*InMemoryCache) All ¶
func (fc *InMemoryCache) All() map[string]flag.Flag
All returns a snapshot of the flags: every flag is a deep copy of the cached one, so the caller can keep the map and change its flags, at any depth, without affecting the cache. The copy is not free: the evaluations read the flags with getFlag or shared, which do not copy.
func (*InMemoryCache) Copy ¶
func (fc *InMemoryCache) Copy() Cache
type Manager ¶
type Manager interface {
UpdateCache(newFlags map[string]dto.DTO, log *fflog.FFLogger, notifyChanges bool) error
Close()
GetFlag(key string) (flag.Flag, error)
// AllFlags returns a snapshot of the flags that the caller is free to change.
AllFlags() (map[string]flag.Flag, error)
// AllFlagsReadOnly returns the flags of the cache without copying them (cheap): the caller must only
// read them, and must not keep them or hand them to code that does not.
AllFlagsReadOnly() (map[string]flag.Flag, error)
GetLatestUpdateDate() time.Time
}
type Option ¶
type Option func(*cacheManagerImpl)
Option customizes the Manager that New creates.
func WithService ¶
WithService makes the manager validate its flags with svc, which the caller owns (and closes). By default the manager creates a Service of its own.