ldbuilders

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: Apache-2.0 Imports: 4 Imported by: 4

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

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 Clause

func Clause(attr lduser.UserAttribute, op ldmodel.Operator, values ...ldvalue.Value) ldmodel.Clause

Clause constructs a basic Clause.

func Negate

func Negate(c ldmodel.Clause) ldmodel.Clause

Negate returns the same Clause with the Negated property set to true.

func Rollout

Rollout constructs a VariationOrRollout with the specified buckets.

func SegmentMatchClause

func SegmentMatchClause(segmentKeys ...string) ldmodel.Clause

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 NewRuleBuilder

func NewRuleBuilder() *RuleBuilder

NewRuleBuilder creates a RuleBuilder.

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

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

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

BucketBy sets the rule's BucketBy property.

func (*SegmentRuleBuilder) Build

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

ID sets the rule's ID property.

func (*SegmentRuleBuilder) Weight

func (b *SegmentRuleBuilder) Weight(value int) *SegmentRuleBuilder

Weight sets the rule's Weight property.

Jump to

Keyboard shortcuts

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