Documentation ¶
Overview ¶
Package ldbuilders contains helpers for constructing the data model objects defined by ldmodel.
This is used mainly in test code, to avoid unnecessary dependencies on implementation details of the data model (such as the use of pointers for optional values).
Index ¶
- func Bucket(variationIndex int, weight int) ldmodel.WeightedVariation
- func BucketUntracked(variationIndex int, weight int) ldmodel.WeightedVariation
- func Clause(attr lduser.UserAttribute, op ldmodel.Operator, values ...ldvalue.Value) ldmodel.Clause
- func Experiment(seed int32, buckets ...ldmodel.WeightedVariation) ldmodel.VariationOrRollout
- func Negate(c ldmodel.Clause) ldmodel.Clause
- func Rollout(buckets ...ldmodel.WeightedVariation) ldmodel.VariationOrRollout
- func SegmentMatchClause(segmentKeys ...string) ldmodel.Clause
- func Variation(variationIndex int) ldmodel.VariationOrRollout
- type FlagBuilder
- func (b *FlagBuilder) AddPrerequisite(key string, variationIndex int) *FlagBuilder
- func (b *FlagBuilder) AddRule(r *RuleBuilder) *FlagBuilder
- func (b *FlagBuilder) AddTarget(variationIndex int, keys ...string) *FlagBuilder
- func (b *FlagBuilder) Build() ldmodel.FeatureFlag
- func (b *FlagBuilder) ClientSideUsingEnvironmentID(value bool) *FlagBuilder
- func (b *FlagBuilder) ClientSideUsingMobileKey(value bool) *FlagBuilder
- func (b *FlagBuilder) DebugEventsUntilDate(t ldtime.UnixMillisecondTime) *FlagBuilder
- func (b *FlagBuilder) Deleted(value bool) *FlagBuilder
- func (b *FlagBuilder) Fallthrough(vr ldmodel.VariationOrRollout) *FlagBuilder
- func (b *FlagBuilder) FallthroughVariation(variationIndex int) *FlagBuilder
- func (b *FlagBuilder) OffVariation(variationIndex int) *FlagBuilder
- func (b *FlagBuilder) On(value bool) *FlagBuilder
- func (b *FlagBuilder) Salt(value string) *FlagBuilder
- func (b *FlagBuilder) SingleVariation(value ldvalue.Value) *FlagBuilder
- func (b *FlagBuilder) TrackEvents(value bool) *FlagBuilder
- func (b *FlagBuilder) TrackEventsFallthrough(value bool) *FlagBuilder
- func (b *FlagBuilder) Variations(values ...ldvalue.Value) *FlagBuilder
- func (b *FlagBuilder) Version(value int) *FlagBuilder
- type RuleBuilder
- func (b *RuleBuilder) Build() ldmodel.FlagRule
- func (b *RuleBuilder) Clauses(clauses ...ldmodel.Clause) *RuleBuilder
- func (b *RuleBuilder) ID(id string) *RuleBuilder
- func (b *RuleBuilder) TrackEvents(value bool) *RuleBuilder
- func (b *RuleBuilder) Variation(variationIndex int) *RuleBuilder
- func (b *RuleBuilder) VariationOrRollout(vr ldmodel.VariationOrRollout) *RuleBuilder
- type SegmentBuilder
- func (b *SegmentBuilder) AddRule(r *SegmentRuleBuilder) *SegmentBuilder
- func (b *SegmentBuilder) Build() ldmodel.Segment
- func (b *SegmentBuilder) Excluded(keys ...string) *SegmentBuilder
- func (b *SegmentBuilder) Generation(value int) *SegmentBuilder
- func (b *SegmentBuilder) Included(keys ...string) *SegmentBuilder
- func (b *SegmentBuilder) Salt(value string) *SegmentBuilder
- func (b *SegmentBuilder) Unbounded(value bool) *SegmentBuilder
- func (b *SegmentBuilder) Version(value int) *SegmentBuilder
- type SegmentRuleBuilder
- func (b *SegmentRuleBuilder) BucketBy(attr lduser.UserAttribute) *SegmentRuleBuilder
- func (b *SegmentRuleBuilder) Build() ldmodel.SegmentRule
- func (b *SegmentRuleBuilder) Clauses(clauses ...ldmodel.Clause) *SegmentRuleBuilder
- func (b *SegmentRuleBuilder) ID(id string) *SegmentRuleBuilder
- func (b *SegmentRuleBuilder) Weight(value int) *SegmentRuleBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bucket ¶
func Bucket(variationIndex int, weight int) ldmodel.WeightedVariation
Bucket constructs a WeightedVariation with the specified variation index and weight.
func BucketUntracked ¶ added in v1.3.0
func BucketUntracked(variationIndex int, weight int) ldmodel.WeightedVariation
BucketUntracked constructs a WeightedVariation with the specified variation index and weight, where users in this bucket will not have tracking events sent.
func Experiment ¶ added in v1.3.0
func Experiment(seed int32, buckets ...ldmodel.WeightedVariation) ldmodel.VariationOrRollout
Experiment constructs a VariationOrRollout representing an experiment with the specified buckets.
func Rollout ¶
func Rollout(buckets ...ldmodel.WeightedVariation) ldmodel.VariationOrRollout
Rollout constructs a VariationOrRollout with the specified buckets.
func SegmentMatchClause ¶
SegmentMatchClause constructs a Clause that uses the segmentMatch operator.
func Variation ¶
func Variation(variationIndex int) ldmodel.VariationOrRollout
Variation constructs a VariationOrRollout with the specified variation index.
Types ¶
type FlagBuilder ¶
type FlagBuilder struct {
// contains filtered or unexported fields
}
FlagBuilder provides a builder pattern for FeatureFlag.
func NewFlagBuilder ¶
func NewFlagBuilder(key string) *FlagBuilder
NewFlagBuilder creates a FlagBuilder.
func (*FlagBuilder) AddPrerequisite ¶
func (b *FlagBuilder) AddPrerequisite(key string, variationIndex int) *FlagBuilder
AddPrerequisite adds a flag prerequisite.
func (*FlagBuilder) AddRule ¶
func (b *FlagBuilder) AddRule(r *RuleBuilder) *FlagBuilder
AddRule adds a flag rule.
func (*FlagBuilder) AddTarget ¶
func (b *FlagBuilder) AddTarget(variationIndex int, keys ...string) *FlagBuilder
AddTarget adds a user target set.
func (*FlagBuilder) Build ¶
func (b *FlagBuilder) Build() ldmodel.FeatureFlag
Build returns the configured FeatureFlag.
func (*FlagBuilder) ClientSideUsingEnvironmentID ¶
func (b *FlagBuilder) ClientSideUsingEnvironmentID(value bool) *FlagBuilder
ClientSideUsingEnvironmentID sets the flag's ClientSideAvailability.UsingEnvironmentID property. By default, this is false. Setting this property also forces the flag to use the newer serialization schema so both UsingEnvironmentID and UsingMobileKey will be explicitly specified.
func (*FlagBuilder) ClientSideUsingMobileKey ¶
func (b *FlagBuilder) ClientSideUsingMobileKey(value bool) *FlagBuilder
ClientSideUsingMobileKey sets the flag's ClientSideAvailability.UsingMobileKey property. By default, this is true. Setting this property also forces the flag to use the newer serialization schema so both UsingEnvironmentID and UsingMobileKey will be explicitly specified.
func (*FlagBuilder) DebugEventsUntilDate ¶
func (b *FlagBuilder) DebugEventsUntilDate(t ldtime.UnixMillisecondTime) *FlagBuilder
DebugEventsUntilDate sets the flag's DebugEventsUntilDate property.
func (*FlagBuilder) Deleted ¶
func (b *FlagBuilder) Deleted(value bool) *FlagBuilder
Deleted sets the flag's Deleted property.
func (*FlagBuilder) Fallthrough ¶
func (b *FlagBuilder) Fallthrough(vr ldmodel.VariationOrRollout) *FlagBuilder
Fallthrough sets the flag's Fallthrough property.
func (*FlagBuilder) FallthroughVariation ¶
func (b *FlagBuilder) FallthroughVariation(variationIndex int) *FlagBuilder
FallthroughVariation sets the flag's Fallthrough property to a fixed variation.
func (*FlagBuilder) OffVariation ¶
func (b *FlagBuilder) OffVariation(variationIndex int) *FlagBuilder
OffVariation sets the flag's OffVariation property.
func (*FlagBuilder) On ¶
func (b *FlagBuilder) On(value bool) *FlagBuilder
On sets the flag's On property.
func (*FlagBuilder) Salt ¶
func (b *FlagBuilder) Salt(value string) *FlagBuilder
Salt sets the flag's Salt property.
func (*FlagBuilder) SingleVariation ¶
func (b *FlagBuilder) SingleVariation(value ldvalue.Value) *FlagBuilder
SingleVariation configures the flag to have only one variation value which it always returns.
func (*FlagBuilder) TrackEvents ¶
func (b *FlagBuilder) TrackEvents(value bool) *FlagBuilder
TrackEvents sets the flag's TrackEvents property.
func (*FlagBuilder) TrackEventsFallthrough ¶
func (b *FlagBuilder) TrackEventsFallthrough(value bool) *FlagBuilder
TrackEventsFallthrough sets the flag's TrackEventsFallthrough property.
func (*FlagBuilder) Variations ¶
func (b *FlagBuilder) Variations(values ...ldvalue.Value) *FlagBuilder
Variations sets the flag's list of variation values.
func (*FlagBuilder) Version ¶
func (b *FlagBuilder) Version(value int) *FlagBuilder
Version sets the flag's Version property.
type RuleBuilder ¶
type RuleBuilder struct {
// contains filtered or unexported fields
}
RuleBuilder provides a builder pattern for FlagRule.
func (*RuleBuilder) Build ¶
func (b *RuleBuilder) Build() ldmodel.FlagRule
Build returns the configured FlagRule.
func (*RuleBuilder) Clauses ¶
func (b *RuleBuilder) Clauses(clauses ...ldmodel.Clause) *RuleBuilder
Clauses sets the rule's list of clauses.
func (*RuleBuilder) ID ¶
func (b *RuleBuilder) ID(id string) *RuleBuilder
ID sets the rule's ID property.
func (*RuleBuilder) TrackEvents ¶
func (b *RuleBuilder) TrackEvents(value bool) *RuleBuilder
TrackEvents sets the rule's TrackEvents property.
func (*RuleBuilder) Variation ¶
func (b *RuleBuilder) Variation(variationIndex int) *RuleBuilder
Variation sets the rule to use a fixed variation.
func (*RuleBuilder) VariationOrRollout ¶
func (b *RuleBuilder) VariationOrRollout(vr ldmodel.VariationOrRollout) *RuleBuilder
VariationOrRollout sets the rule to use either a variation or a percentage rollout.
type SegmentBuilder ¶
type SegmentBuilder struct {
// contains filtered or unexported fields
}
SegmentBuilder provides a builder pattern for Segment.
func NewSegmentBuilder ¶
func NewSegmentBuilder(key string) *SegmentBuilder
NewSegmentBuilder creates a SegmentBuilder.
func (*SegmentBuilder) AddRule ¶
func (b *SegmentBuilder) AddRule(r *SegmentRuleBuilder) *SegmentBuilder
AddRule adds a rule to the segment.
func (*SegmentBuilder) Build ¶
func (b *SegmentBuilder) Build() ldmodel.Segment
Build returns the configured Segment.
func (*SegmentBuilder) Excluded ¶
func (b *SegmentBuilder) Excluded(keys ...string) *SegmentBuilder
Excluded sets the segment's Excluded list.
func (*SegmentBuilder) Generation ¶ added in v1.4.0
func (b *SegmentBuilder) Generation(value int) *SegmentBuilder
Generation sets the segment's Generation property.
func (*SegmentBuilder) Included ¶
func (b *SegmentBuilder) Included(keys ...string) *SegmentBuilder
Included sets the segment's Included list.
func (*SegmentBuilder) Salt ¶
func (b *SegmentBuilder) Salt(value string) *SegmentBuilder
Salt sets the segment's Salt property.
func (*SegmentBuilder) Unbounded ¶
func (b *SegmentBuilder) Unbounded(value bool) *SegmentBuilder
Unbounded sets the segment's Unbounded property. "Unbounded segment" is the historical name for a big segment.
func (*SegmentBuilder) Version ¶
func (b *SegmentBuilder) Version(value int) *SegmentBuilder
Version sets the segment's Version property.
type SegmentRuleBuilder ¶
type SegmentRuleBuilder struct {
// contains filtered or unexported fields
}
SegmentRuleBuilder provides a builder pattern for SegmentRule.
func NewSegmentRuleBuilder ¶
func NewSegmentRuleBuilder() *SegmentRuleBuilder
NewSegmentRuleBuilder creates a SegmentRuleBuilder.
func (*SegmentRuleBuilder) BucketBy ¶
func (b *SegmentRuleBuilder) BucketBy(attr lduser.UserAttribute) *SegmentRuleBuilder
BucketBy sets the rule's BucketBy property.
func (*SegmentRuleBuilder) Build ¶
func (b *SegmentRuleBuilder) Build() ldmodel.SegmentRule
Build returns the configured SegmentRule.
func (*SegmentRuleBuilder) Clauses ¶
func (b *SegmentRuleBuilder) Clauses(clauses ...ldmodel.Clause) *SegmentRuleBuilder
Clauses sets the rule's list of clauses.
func (*SegmentRuleBuilder) ID ¶
func (b *SegmentRuleBuilder) ID(id string) *SegmentRuleBuilder
ID sets the rule's ID property.
func (*SegmentRuleBuilder) Weight ¶
func (b *SegmentRuleBuilder) Weight(value int) *SegmentRuleBuilder
Weight sets the rule's Weight property.