domain

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SecondsToStale = 90 * 24 * 60 * 60 // 90 days

)

Variables

View Source
var (
	ErrAlreadyEnabled       = errors.New("feature: already enabled")
	ErrAlreadyDisabled      = errors.New("feature: already disabled")
	ErrLastUsedInfoNotFound = errors.New("feature: last used info not found")

	ErrCycleExists     = errors.New("feature: cycle exists in features")
	ErrFeatureNotFound = errors.New("feature: feature not found")
)

Functions

func FeatureLastUsedInfoID

func FeatureLastUsedInfoID(featureID string, version int32) string

func GetFeaturesDependedOnTargets added in v0.4.6

func GetFeaturesDependedOnTargets(
	targets []*feature.Feature, all map[string]*feature.Feature,
) map[string]*feature.Feature

getFeaturesDependedOnTargets returns the features that are depended on the target features. targetFeatures are included in the result.

func GetFeaturesDependsOnTargets added in v0.4.6

func GetFeaturesDependsOnTargets(
	targets []*feature.Feature, all map[string]*feature.Feature,
) map[string]*feature.Feature

getFeaturesDependsOnTargets returns the features that depend on the target features. targetFeatures are included in the result.

func HasFeaturesDependsOnTargets added in v0.4.6

func HasFeaturesDependsOnTargets(
	targets []*feature.Feature, all []*feature.Feature,
) bool

HasFeaturesDependsOnTargets returns true if there are features that depend on the target features. This is a thin wrapper of GetFeaturesDependsOnTargets.

func SegmentUserID

func SegmentUserID(segmentID string, userID string, state featureproto.SegmentUser_State) string

func TopologicalSort

func TopologicalSort(features []*feature.Feature) ([]*feature.Feature, error)

This logic is based on https://en.wikipedia.org/wiki/Topological_sorting. Note: This algorithm is not an exact topological sort because the order is reversed (=from upstream to downstream).

func ValidateFeatureDependencies added in v0.4.6

func ValidateFeatureDependencies(fs []*feature.Feature) error

Types

type Feature

type Feature struct {
	*feature.Feature
}

func NewFeature

func NewFeature(
	id, name, description string,
	variationType feature.Feature_VariationType,
	variations []*feature.Variation,
	tags []string,
	defaultOnVariationIndex, defaultOffVariationIndex int,
	maintainer string,
) (*Feature, error)

func (*Feature) AddClause

func (f *Feature) AddClause(rule string, clause *feature.Clause) error

func (*Feature) AddClauseValue

func (f *Feature) AddClauseValue(rule string, clause string, value string) error

func (*Feature) AddPrerequisite

func (f *Feature) AddPrerequisite(fID, variationID string) error

func (*Feature) AddRule

func (f *Feature) AddRule(rule *feature.Rule) error

func (*Feature) AddTag

func (f *Feature) AddTag(tag string) error

func (*Feature) AddUserToVariation

func (f *Feature) AddUserToVariation(variation string, user string) error

func (*Feature) AddVariation

func (f *Feature) AddVariation(id string, value string, name string, description string) error

func (*Feature) Archive

func (f *Feature) Archive() error

func (*Feature) ChangeClauseAttribute

func (f *Feature) ChangeClauseAttribute(rule string, clause string, attribute string) error

func (*Feature) ChangeClauseOperator

func (f *Feature) ChangeClauseOperator(rule string, clause string, operator feature.Clause_Operator) error

func (*Feature) ChangeDefaultStrategy

func (f *Feature) ChangeDefaultStrategy(s *feature.Strategy) error

func (*Feature) ChangeDescription

func (f *Feature) ChangeDescription(description string) error

func (*Feature) ChangeFixedStrategy

func (f *Feature) ChangeFixedStrategy(ruleID string, strategy *feature.FixedStrategy) error

func (*Feature) ChangeOffVariation

func (f *Feature) ChangeOffVariation(id string) error

func (*Feature) ChangePrerequisiteVariation

func (f *Feature) ChangePrerequisiteVariation(fID, variationID string) error

func (*Feature) ChangeRolloutStrategy

func (f *Feature) ChangeRolloutStrategy(ruleID string, strategy *feature.RolloutStrategy) error

func (*Feature) ChangeRuleStrategy

func (f *Feature) ChangeRuleStrategy(ruleID string, strategy *feature.Strategy) error

func (*Feature) ChangeRulesOrder added in v0.4.0

func (f *Feature) ChangeRulesOrder(ruleIDs []string) error

func (*Feature) ChangeVariationDescription

func (f *Feature) ChangeVariationDescription(id string, description string) error

func (*Feature) ChangeVariationName

func (f *Feature) ChangeVariationName(id string, name string) error

func (*Feature) ChangeVariationValue

func (f *Feature) ChangeVariationValue(id string, value string) error

func (*Feature) Clone

func (f *Feature) Clone(
	maintainer string,
) (*Feature, error)

func (*Feature) Delete

func (f *Feature) Delete() error

func (*Feature) DeleteClause

func (f *Feature) DeleteClause(rule string, clause string) error

func (*Feature) DeleteRule

func (f *Feature) DeleteRule(rule string) error

func (*Feature) Disable

func (f *Feature) Disable() error

func (*Feature) Enable

func (f *Feature) Enable() error

func (*Feature) FeatureIDsDependsOn added in v0.4.5

func (f *Feature) FeatureIDsDependsOn() []string

FeatureIDsDependsOn returns the ids of the features that this feature depends on.

func (*Feature) IncrementVersion

func (f *Feature) IncrementVersion() error

func (*Feature) IsArchivedBeforeLastThirtyDays added in v0.3.0

func (f *Feature) IsArchivedBeforeLastThirtyDays() bool

IsArchivedBeforeLastThirtyDays returns a bool value indicating whether the feature flag was archived within the last thirty days.

func (*Feature) IsDisabledAndOffVariationEmpty added in v0.3.0

func (f *Feature) IsDisabledAndOffVariationEmpty() bool

func (*Feature) IsStale

func (f *Feature) IsStale(t time.Time) bool

func (*Feature) ListSegmentIDs

func (f *Feature) ListSegmentIDs() []string

func (*Feature) RemoveClauseValue

func (f *Feature) RemoveClauseValue(rule string, clause string, value string) error

func (*Feature) RemovePrerequisite

func (f *Feature) RemovePrerequisite(fID string) error

func (*Feature) RemoveTag

func (f *Feature) RemoveTag(tag string) error

func (*Feature) RemoveUserFromVariation

func (f *Feature) RemoveUserFromVariation(variation string, user string) error

func (*Feature) RemoveVariation

func (f *Feature) RemoveVariation(id string) error

func (*Feature) Rename

func (f *Feature) Rename(name string) error

func (*Feature) ResetSamplingSeed

func (f *Feature) ResetSamplingSeed() error

func (*Feature) Unarchive

func (f *Feature) Unarchive() error

func (*Feature) Update added in v0.4.6

func (f *Feature) Update(
	name, description *wrapperspb.StringValue,
	tags []string,
	enabled *wrapperspb.BoolValue,
	archived *wrapperspb.BoolValue,
	variations []*feature.Variation,
	prerequisites []*feature.Prerequisite,
	targets []*feature.Target,
	rules []*feature.Rule,
	defaultStrategy *feature.Strategy,
	offVariation *wrapperspb.StringValue,
) (*Feature, error)

Update returns a new Feature with the updated values.

type FeatureLastUsedInfo

type FeatureLastUsedInfo struct {
	*feature.FeatureLastUsedInfo
}

func NewFeatureLastUsedInfo

func NewFeatureLastUsedInfo(
	featureID string,
	version int32,
	lastUsedAt int64,
	clientVersion string,
) *FeatureLastUsedInfo

func (*FeatureLastUsedInfo) ID

func (f *FeatureLastUsedInfo) ID() string

func (*FeatureLastUsedInfo) SetClientVersion

func (f *FeatureLastUsedInfo) SetClientVersion(version string) error

func (*FeatureLastUsedInfo) UsedAt

func (f *FeatureLastUsedInfo) UsedAt(v int64)

type FlagTrigger added in v0.4.0

type FlagTrigger struct {
	*proto.FlagTrigger
}

func NewFlagTrigger added in v0.4.0

func NewFlagTrigger(
	environmentId string,
	cmd *proto.CreateFlagTriggerCommand,
) (*FlagTrigger, error)

func (*FlagTrigger) ChangeDescription added in v0.4.0

func (ft *FlagTrigger) ChangeDescription(description string) error

func (*FlagTrigger) Disable added in v0.4.0

func (ft *FlagTrigger) Disable() error

func (*FlagTrigger) Enable added in v0.4.0

func (ft *FlagTrigger) Enable() error

func (*FlagTrigger) GenerateToken added in v0.4.0

func (ft *FlagTrigger) GenerateToken() error

func (*FlagTrigger) UpdateTriggerUsage added in v0.4.0

func (ft *FlagTrigger) UpdateTriggerUsage() error

type Mark

type Mark int

type Segment

type Segment struct {
	*featureproto.Segment
}

func NewSegment

func NewSegment(name string, description string) (*Segment, error)

func (*Segment) AddClause

func (s *Segment) AddClause(ruleID string, clause *featureproto.Clause) error

func (*Segment) AddClauseValue

func (s *Segment) AddClauseValue(ruleID string, clauseID string, value string) error

func (*Segment) AddIncludedUserCount

func (s *Segment) AddIncludedUserCount(count int64)

func (*Segment) AddRule

func (s *Segment) AddRule(rule *featureproto.Rule) error

func (*Segment) ChangeClauseAttribute

func (s *Segment) ChangeClauseAttribute(ruleID string, clauseID string, attribute string) error

func (*Segment) ChangeClauseOperator

func (s *Segment) ChangeClauseOperator(ruleID string, clauseID string, operator featureproto.Clause_Operator) error

func (*Segment) ChangeDescription

func (s *Segment) ChangeDescription(description string) error

func (*Segment) ChangeName

func (s *Segment) ChangeName(name string) error

func (*Segment) DeleteClause

func (s *Segment) DeleteClause(ruleID string, clauseID string) error

func (*Segment) DeleteRule

func (s *Segment) DeleteRule(rule string) error

func (*Segment) RemoveClauseValue

func (s *Segment) RemoveClauseValue(ruleID string, clauseID string, value string) error

func (*Segment) RemoveIncludedUserCount

func (s *Segment) RemoveIncludedUserCount(count int64)

func (*Segment) SetDeleted

func (s *Segment) SetDeleted() error

func (*Segment) SetIncludedUserCount

func (s *Segment) SetIncludedUserCount(count int64)

func (*Segment) SetStatus

func (s *Segment) SetStatus(status featureproto.Segment_Status)

func (*Segment) UpdateSegment added in v1.2.0

func (s *Segment) UpdateSegment(
	name *wrapperspb.StringValue,
	description *wrapperspb.StringValue,
) (*Segment, error)

type SegmentUser

type SegmentUser struct {
	*featureproto.SegmentUser
}

func NewSegmentUser

func NewSegmentUser(segmentID string, userID string, state featureproto.SegmentUser_State, deleted bool) *SegmentUser

type Tag

type Tag struct {
	*feature.Tag
}

func NewTag

func NewTag(name string) (*Tag, error)

Jump to

Keyboard shortcuts

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