domain

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

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

)

Variables

View Source
var (
	ErrCycleExists = errors.New("feature: cycle exists in features")

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

Functions

func EvaluateFeatures deprecated

func EvaluateFeatures(
	fs []*featureproto.Feature,
	user *userproto.User,
	mapSegmentUsers map[string][]*featureproto.SegmentUser,
	targetTag string,
) (*featureproto.UserEvaluations, error)

Deprecated: use EvaluateFeaturesByEvaluatedAt instead. This function will be removed once all the SDK clients are updated.

func EvaluateFeaturesByEvaluatedAt added in v0.3.0

func EvaluateFeaturesByEvaluatedAt(
	fs []*featureproto.Feature,
	user *userproto.User,
	mapSegmentUsers map[string][]*featureproto.SegmentUser,
	prevUEID string,
	evaluatedAt int64,
	userAttributesUpdated bool,
	targetTag string,
) (*featureproto.UserEvaluations, error)

func EvaluationID

func EvaluationID(featureID string, featureVersion int32, userID string) string

func FeatureLastUsedInfoID

func FeatureLastUsedInfoID(featureID string, version int32) string

func GetPrerequisiteDownwards added in v0.3.0

func GetPrerequisiteDownwards(
	targetFeatures, allFeatures []*featureproto.Feature,
) ([]*featureproto.Feature, error)

GetPrerequisiteDownwards gets the features specified as prerequisite by the targetFeatures.

func GetPrerequisiteUpwards added in v0.3.0

func GetPrerequisiteUpwards(
	targetFeatures, featuresHavePrerequisite []*featureproto.Feature,
) []*featureproto.Feature

GetPrerequisiteUpwards gets the features that have the specified targetFeatures as the prerequisite.

func SegmentUserID

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

func TopologicalSort

func TopologicalSort(features []*featureproto.Feature) ([]*featureproto.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 UserEvaluationsID

func UserEvaluationsID(userID string, userMetadata map[string]string, features []*feature.Feature) string

Types

type Feature

type Feature struct {
	*feature.Feature
	// contains filtered or unexported fields
}

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) 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

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(
	environmentNamespace 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)

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(id string) *Tag

type UserEvaluations

type UserEvaluations struct {
	*feature.UserEvaluations
}

func NewUserEvaluations

func NewUserEvaluations(
	id string,
	evaluations []*feature.Evaluation,
	archivedFeaturesIds []string,
	forceUpdate bool,
) *UserEvaluations

Jump to

Keyboard shortcuts

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