ldbuilders

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 5 Imported by: 3

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 BucketUntracked

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 Clause

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

Clause constructs a basic Clause. The attr parameter is assumed to be a simple attribute name rather than a path reference.

func ClauseRef

func ClauseRef(attrRef ldattr.Ref, op ldmodel.Operator, values ...ldvalue.Value) ldmodel.Clause

ClauseRef constructs a basic Clause, using the ldattr.Ref type for the attribute reference.

func ClauseRefWithKind

func ClauseRefWithKind(
	contextKind ldcontext.Kind,
	attrRef ldattr.Ref,
	op ldmodel.Operator,
	values ...ldvalue.Value,
) ldmodel.Clause

ClauseRefWithKind is like ClauseRef, but also specifies a context kind.

func ClauseWithKind

func ClauseWithKind(
	contextKind ldcontext.Kind,
	attr string,
	op ldmodel.Operator,
	values ...ldvalue.Value,
) ldmodel.Clause

ClauseWithKind is like Clause, but also specifies a context kind.

func Experiment

Experiment constructs a VariationOrRollout representing an experiment with the specified buckets.

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

func (b *FlagBuilder) AddContextTarget(kind ldcontext.Kind, variationIndex int, keys ...string) *FlagBuilder

AddContextTarget adds a target set for any context kind.

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

func (b *SegmentBuilder) ExcludedContextKind(kind ldcontext.Kind, keys ...string) *SegmentBuilder

ExcludedContextKind adds a target to the segment's ExcludedContexts.

func (*SegmentBuilder) Generation

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

func (b *SegmentBuilder) IncludedContextKind(kind ldcontext.Kind, keys ...string) *SegmentBuilder

IncludedContextKind adds a target list to the segment's IncludedContexts.

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

func (b *SegmentBuilder) UnboundedContextKind(kind ldcontext.Kind) *SegmentBuilder

UnboundedContextKind sets the segment's UnboundedContextKind 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

func (b *SegmentRuleBuilder) BucketBy(attr string) *SegmentRuleBuilder

BucketBy sets the rule's BucketBy property. The attr parameter is assumed to be a simple attribute name, rather than a path reference.

func (*SegmentRuleBuilder) BucketByRef

func (b *SegmentRuleBuilder) BucketByRef(attr ldattr.Ref) *SegmentRuleBuilder

BucketByRef sets the rule's BucketBy property using the ldattr.Ref type.

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

func (b *SegmentRuleBuilder) RolloutContextKind(kind ldcontext.Kind) *SegmentRuleBuilder

RolloutContextKind sets the rule's RolloutContextKind 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