assignment

package
v0.0.0-...-12a582f Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFailedAssignmentWeightedChoice returns if there is some
	// inability to select a variant at the set weight
	// when the defaults are returned from Assign
	ErrFailedAssignmentWeightedChoice = errors.New("failed to assign weighted choice")

	// ErrNoVariants Returns when an experiment has no variants
	ErrNoVariants = errors.New("no variants")
)

Functions

This section is empty.

Types

type Probabilistic

type Probabilistic struct {
	Variants []*variant.Variant
	P        float32
}

Probabilistic implements a probabilistic selector of variants

func NewProbabilistic

func NewProbabilistic(variants []*variant.Variant) *Probabilistic

NewProbabilistic returns an initialized Sample operator

func (*Probabilistic) Assign

func (o *Probabilistic) Assign(hash uint64) (*variant.Variant, error)

Assign is not implemented for a Probabilistic Assignment

type Sample

type Sample struct {
	Variants []*variant.Variant
}

Sample implements a sampler for

func NewSample

func NewSample(variants []*variant.Variant) *Sample

NewSample returns an initialized Sample operator

func (*Sample) Assign

func (o *Sample) Assign(hash uint64) (*variant.Variant, error)

Assign is not implemented

type UniformChoice

type UniformChoice struct {
	Variants []*variant.Variant
}

UniformChoice implements an assignment operator for uniform choice selection of variants

func NewUniformChoice

func NewUniformChoice(v []*variant.Variant) *UniformChoice

NewUniformChoice returns an initilized weighted choice assignment operator

func (*UniformChoice) Assign

func (u *UniformChoice) Assign(hash uint64) (*variant.Variant, error)

Assign implements assignment to a variant using a uniform choice configuration

type WeightedChoice

type WeightedChoice struct {
	Variants []*variant.Variant
}

WeightedChoice implements an assignment operator for weighted choice selection of variants

func NewWeightedChoice

func NewWeightedChoice(v []*variant.Variant) *WeightedChoice

NewWeightedChoice returns an initilized weighted choice assignment operator

func (*WeightedChoice) Assign

func (w *WeightedChoice) Assign(hash uint64) (*variant.Variant, error)

Assign implements assignment to a variant using a weighted choice configuration

Jump to

Keyboard shortcuts

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