flagstate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllFlags

type AllFlags struct {
	// contains filtered or unexported fields
}

AllFlags is a snapshot of the state of multiple feature flags with regard to a specific user. This is the return type of the AllFlagsState method of the client. Serializing this object to JSON MarshalJSON() will produce a JSON you can sent to your front-end.

func NewAllFlags

func NewAllFlags() AllFlags

NewAllFlags will create a new AllFlags for a specific user. It sets valid to true, because until we have an error everything is valid.

func (*AllFlags) AddFlag

func (a *AllFlags) AddFlag(flagKey string, state FlagState)

AddFlag is adding a flag in the list for the specific user.

func (*AllFlags) GetFlags

func (a *AllFlags) GetFlags() map[string]FlagState

func (*AllFlags) IsValid

func (a *AllFlags) IsValid() bool

IsValid is a getter to know if the AllFlags object is valid.

func (AllFlags) MarshalJSON

func (a AllFlags) MarshalJSON() ([]byte, error)

MarshalJSON is serializing the object to JSON, it will produce a JSON you can sent to your front-end.

type FlagState

type FlagState struct {
	Value         any                   `json:"value"`
	Timestamp     int64                 `json:"timestamp"`
	VariationType string                `json:"variationType"`
	TrackEvents   bool                  `json:"trackEvents"`
	Failed        bool                  `json:"-"`
	ErrorCode     flag.ErrorCode        `json:"errorCode"`
	ErrorDetails  string                `json:"errorDetails,omitempty"`
	Reason        flag.ResolutionReason `json:"reason"`
	Metadata      map[string]any        `json:"metadata,omitempty"`
}

FlagState represents the state of an individual feature flag, with regard to a specific user, when it was called.

func FromFlagEvaluation

func FromFlagEvaluation(key string, evaluationCtx ffcontext.Context,
	flagCtx flag.Context, currentFlag flag.Flag) FlagState

FromFlagEvaluation builds the state of a flag evaluated now.

func FromFlagEvaluationAt

func FromFlagEvaluationAt(at time.Time, key string, evaluationCtx ffcontext.Context,
	flagCtx flag.Context, currentFlag flag.Flag) FlagState

FromFlagEvaluationAt builds the state of a flag evaluated at the given instant.

Jump to

Keyboard shortcuts

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