memprovider

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: Apache-2.0 Imports: 3 Imported by: 3

README

In-memory provider

InMemoryProvider is an OpenFeature compliant provider implementation with an in-memory flag storage.

While the main usage of this provider is SDK testing, you may use it for minimal OpenFeature use cases where appropriate.

Documentation

Overview

Package memprovider provides an in-memory feature flag provider for OpenFeature.

Index

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 InMemoryEvent struct {
	Value             float64
	Data              map[string]any
	ContextAttributes map[string]any
}

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

func (InMemoryProvider) BooleanEvaluation

func (i InMemoryProvider) BooleanEvaluation(ctx context.Context, flag string, defaultValue bool, flatCtx openfeature.FlattenedContext) openfeature.BoolResolutionDetail

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)

type State

type State string

State of the feature flag

const (
	Enabled  State = "ENABLED"
	Disabled State = "DISABLED"
)

Jump to

Keyboard shortcuts

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