featureflags

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package featureflags provides a feature flag evaluation interface for controlling feature availability per user, with implementations for LaunchDarkly and PostHog.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EvaluationContext

type EvaluationContext struct {
	Attributes   map[string]any
	TargetingKey string
}

EvaluationContext carries targeting information for a single flag evaluation. TargetingKey is the primary subject identifier — typically a user ID, but it can be any stable string a provider's targeting rules can match against. Attributes carry arbitrary additional signals (tenant, plan tier, country, beta cohort, region, etc.) that provider rules can target on.

This type is intentionally repo-owned rather than aliasing the OpenFeature SDK's EvaluationContext: it keeps the openfeature import out of caller code, lets the noop and mock implementations satisfy the signature without importing openfeature, and leaves room to swap providers later. Each provider converts to its own representation internally.

type FeatureFlagManager

type FeatureFlagManager interface {
	// CanUseFeature evaluates a boolean flag. Returns false on error.
	CanUseFeature(ctx context.Context, feature string, evalCtx EvaluationContext) (bool, error)
	// GetStringValue evaluates a string-typed flag, returning defaultValue on error.
	GetStringValue(ctx context.Context, feature, defaultValue string, evalCtx EvaluationContext) (string, error)
	// GetInt64Value evaluates an int64-typed flag, returning defaultValue on error.
	GetInt64Value(ctx context.Context, feature string, defaultValue int64, evalCtx EvaluationContext) (int64, error)
	// GetFloat64Value evaluates a float64-typed flag, returning defaultValue on error.
	GetFloat64Value(ctx context.Context, feature string, defaultValue float64, evalCtx EvaluationContext) (float64, error)
	// GetObjectValue evaluates an object-typed (JSON) flag, returning defaultValue
	// on error. The concrete type of the returned value is provider-specific —
	// callers typically type-assert or json.Marshal it back into a known struct.
	GetObjectValue(ctx context.Context, feature string, defaultValue any, evalCtx EvaluationContext) (any, error)
	// Close releases any backend resources held by the FeatureFlagManager.
	Close() error
}

FeatureFlagManager evaluates feature flags. Implementations must be safe for concurrent use.

Directories

Path Synopsis
Package mock provides mock implementations of the featureflags package's interfaces.
Package mock provides mock implementations of the featureflags package's interfaces.

Jump to

Keyboard shortcuts

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