Versions in this module Expand all Collapse all v1 v1.0.0 Oct 28, 2025 Changes in this version + const Version + var ErrFlagNotFound = errors.New("flag not found") + var ErrInvalidCondition = errors.New("invalid condition") + var ErrInvalidOperator = errors.New("invalid operator") + var ErrInvalidRollout = errors.New("rollout must be between 0 and 100") + var ErrRolloutKeyMissing = errors.New("rollout key missing from context") + type Condition struct + Attribute string + Negate bool + Operator Operator + Value interface{} + func (c *Condition) Validate() error + type Context map[string]interface + func (c Context) Get(key string) (interface{}, bool) + func (c Context) GetString(key string) string + func (c Context) Set(key string, value interface{}) + type DefaultRolloutStrategy struct + func NewDefaultRolloutStrategy(hasher hash.Hasher) *DefaultRolloutStrategy + func (r *DefaultRolloutStrategy) GetVariant(flag *Flag, ctx Context) (string, error) + func (r *DefaultRolloutStrategy) ShouldRollout(flag *Flag, ctx Context) (bool, error) + type Flag struct + Conditions []Condition + DefaultVariant string + Enabled bool + Name string + Rollout int + RolloutKey string + Variants []Variant + func (f *Flag) GetRolloutKey() string + func (f *Flag) HasVariants() bool + func (f *Flag) Validate() error + type Operator string + const OperatorContains + const OperatorEndsWith + const OperatorEqual + const OperatorGreaterThan + const OperatorGreaterThanOrEqual + const OperatorIn + const OperatorLessThan + const OperatorLessThanOrEqual + const OperatorNotEqual + const OperatorNotIn + const OperatorRegex + const OperatorStartsWith + func (o Operator) IsValid() bool + type RolloutStrategy interface + GetVariant func(flag *Flag, ctx Context) (string, error) + ShouldRollout func(flag *Flag, ctx Context) (bool, error) + type Store struct + func NewStore(opts ...StoreOption) *Store + func (s *Store) AddFlag(flag *Flag) error + func (s *Store) AddFlags(flags []*Flag) error + func (s *Store) Clear() + func (s *Store) GetFlag(name string) (*Flag, error) + func (s *Store) GetRolloutStrategy() RolloutStrategy + func (s *Store) GetVariant(name string, ctx Context) (string, bool) + func (s *Store) GetVariantWithError(name string, ctx Context) (string, bool, error) + func (s *Store) IsEnabled(name string, ctx Context) bool + func (s *Store) IsEnabledWithError(name string, ctx Context) (bool, error) + func (s *Store) ListFlags() []string + func (s *Store) RemoveFlag(name string) + func (s *Store) Size() int + type StoreOption func(*Store) + func WithSwitchback(opts ...SwitchbackOption) StoreOption + type SwitchbackInfo struct + CurrentDay int + CurrentInterval int + IntervalDuration time.Duration + TimeUntilSwitch time.Duration + func GetSwitchbackInfo(store *Store) *SwitchbackInfo + type SwitchbackOption func(*SwitchbackRolloutStrategy) + func WithDailySwap(enabled bool) SwitchbackOption + func WithIntervalMinutes(minutes int) SwitchbackOption + func WithStartTime(t time.Time) SwitchbackOption + type SwitchbackRolloutStrategy struct + func NewSwitchbackRolloutStrategy(opts ...SwitchbackOption) *SwitchbackRolloutStrategy + func (s *SwitchbackRolloutStrategy) GetCurrentDay() int + func (s *SwitchbackRolloutStrategy) GetCurrentInterval() int + func (s *SwitchbackRolloutStrategy) GetInfo() SwitchbackInfo + func (s *SwitchbackRolloutStrategy) GetTimeUntilNextSwitch() time.Duration + func (s *SwitchbackRolloutStrategy) GetVariant(flag *Flag, ctx Context) (string, error) + func (s *SwitchbackRolloutStrategy) ShouldRollout(flag *Flag, ctx Context) (bool, error) + func (s *SwitchbackRolloutStrategy) String() string + type Variant struct + Conditions []Condition + Name string + Weight int