Documentation
¶
Overview ¶
Package memprovider provides an in-memory feature flag provider for OpenFeature.
Index ¶
- type ContextEvaluator
- type InMemoryEvent
- type InMemoryFlag
- type InMemoryProvider
- func (i *InMemoryProvider) BooleanEvaluation(ctx context.Context, flag string, defaultValue bool, ...) openfeature.BoolResolutionDetail
- func (i *InMemoryProvider) EventChannel() <-chan openfeature.Event
- func (i *InMemoryProvider) FloatEvaluation(ctx context.Context, flag string, defaultValue float64, ...) openfeature.FloatResolutionDetail
- func (i *InMemoryProvider) Hooks() []openfeature.Hook
- func (i *InMemoryProvider) IntEvaluation(ctx context.Context, flag string, defaultValue int64, ...) openfeature.IntResolutionDetail
- func (i *InMemoryProvider) Metadata() openfeature.Metadata
- func (i *InMemoryProvider) ObjectEvaluation(ctx context.Context, flag string, defaultValue any, ...) openfeature.InterfaceResolutionDetail
- func (i *InMemoryProvider) StringEvaluation(ctx context.Context, flag string, defaultValue string, ...) openfeature.StringResolutionDetail
- func (i *InMemoryProvider) Track(ctx context.Context, trackingEventName string, ...)
- func (i *InMemoryProvider) TrackingEvents(trackingEventName string) []InMemoryEvent
- func (i *InMemoryProvider) UpdateFlags(flags map[string]InMemoryFlag)
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextEvaluator ¶
type ContextEvaluator *func(this InMemoryFlag, flatCtx openfeature.FlattenedContext) (any, openfeature.ProviderResolutionDetail)
ContextEvaluator is a callback to perform openfeature.EvaluationContext backed evaluations. This is a callback implemented by the flag definer.
type InMemoryEvent ¶ added in v1.14.0
type InMemoryFlag ¶
type InMemoryFlag struct {
Key string
State State
DefaultVariant string
Variants map[string]any
ContextEvaluator ContextEvaluator
}
InMemoryFlag is the feature flag representation accepted by InMemoryProvider
func (*InMemoryFlag) Resolve ¶
func (flag *InMemoryFlag) Resolve(defaultValue any, flatCtx openfeature.FlattenedContext) ( any, openfeature.ProviderResolutionDetail, )
type InMemoryProvider ¶
type InMemoryProvider struct {
// contains filtered or unexported fields
}
func NewInMemoryProvider ¶
func NewInMemoryProvider(from map[string]InMemoryFlag) *InMemoryProvider
NewInMemoryProvider returns a provider serving a copy of the given flag set.
The map itself is copied, so mutating it afterwards does not affect the provider. The copy is shallow: the provider takes ownership of each flag's Variants and ContextEvaluator, which must not be mutated once the flag has been handed over. Use InMemoryProvider.UpdateFlags to change the flag set.
func (*InMemoryProvider) BooleanEvaluation ¶
func (i *InMemoryProvider) BooleanEvaluation(ctx context.Context, flag string, defaultValue bool, flatCtx openfeature.FlattenedContext) openfeature.BoolResolutionDetail
func (*InMemoryProvider) EventChannel ¶ added in v1.20.0
func (i *InMemoryProvider) EventChannel() <-chan openfeature.Event
EventChannel implements openfeature.EventHandler. The channel is never closed: the SDK stops listening via its own shutdown signal, and closing would panic a subsequent UpdateFlags.
func (*InMemoryProvider) FloatEvaluation ¶
func (i *InMemoryProvider) FloatEvaluation(ctx context.Context, flag string, defaultValue float64, flatCtx openfeature.FlattenedContext) openfeature.FloatResolutionDetail
func (*InMemoryProvider) Hooks ¶
func (i *InMemoryProvider) Hooks() []openfeature.Hook
func (*InMemoryProvider) IntEvaluation ¶
func (i *InMemoryProvider) IntEvaluation(ctx context.Context, flag string, defaultValue int64, flatCtx openfeature.FlattenedContext) openfeature.IntResolutionDetail
func (*InMemoryProvider) Metadata ¶
func (i *InMemoryProvider) Metadata() openfeature.Metadata
func (*InMemoryProvider) ObjectEvaluation ¶
func (i *InMemoryProvider) ObjectEvaluation(ctx context.Context, flag string, defaultValue any, flatCtx openfeature.FlattenedContext) openfeature.InterfaceResolutionDetail
func (*InMemoryProvider) StringEvaluation ¶
func (i *InMemoryProvider) StringEvaluation(ctx context.Context, flag string, defaultValue string, flatCtx openfeature.FlattenedContext) openfeature.StringResolutionDetail
func (*InMemoryProvider) Track ¶ added in v1.14.0
func (i *InMemoryProvider) Track(ctx context.Context, trackingEventName string, evalCtx openfeature.EvaluationContext, details openfeature.TrackingEventDetails)
func (*InMemoryProvider) TrackingEvents ¶ added in v1.20.0
func (i *InMemoryProvider) TrackingEvents(trackingEventName string) []InMemoryEvent
TrackingEvents returns the events Track recorded for trackingEventName, in the order they were recorded, and an empty slice for a name never tracked.
The returned slice and each event's Data and ContextAttributes maps are copied. Values within those maps and the event Value are not cloned.
func (*InMemoryProvider) UpdateFlags ¶ added in v1.20.0
func (i *InMemoryProvider) UpdateFlags(flags map[string]InMemoryFlag)
UpdateFlags replaces the flag set and emits a PROVIDER_CONFIGURATION_CHANGED event naming the union of the previous and the new flag keys, as required by Appendix A of the OpenFeature specification.
As in NewInMemoryProvider, the map is copied shallowly: the provider takes ownership of each flag's Variants and ContextEvaluator, which must not be mutated once the flag has been handed over.
Events are buffered, so an update made before the provider is registered is still delivered once the SDK attaches a listener. Once the buffer is full the event is dropped rather than blocking the caller.