Documentation ¶
Index ¶
Constants ¶
const ( // default total weight. DefaultTotalWeight float64 = 1.0 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a a/b testing instance interface.
func NewRoundRobin ¶
func NewRoundRobin(tests []RoundRobinTest) Client
NewRoundRobin creates a new ab-test with round-robin strategy instance.
func NewWeightedRandom ¶
func NewWeightedRandom(tests []WeightedRandomTest) Client
NewWeightedRandom creates a new ab-test with weighted random strategy instance.
type RoundRobin ¶
type RoundRobin struct {
// contains filtered or unexported fields
}
RoundRobin is a ab-test with round-robin strategy.
func (*RoundRobin) Pick ¶
func (c *RoundRobin) Pick() (id string, callback func() error)
Pick using round-robin to choose test returns a test.
func (*RoundRobin) Run ¶
func (c *RoundRobin) Run() error
Run using round-robin to choose test and execute the callback of the test.
type RoundRobinTest ¶
RoundRobinTest is a test data for round-robin strategy.
type WeightedRandom ¶
type WeightedRandom struct {
// contains filtered or unexported fields
}
WeightedRandom is a ab-test with weighted random strategy.
func (*WeightedRandom) Pick ¶
func (c *WeightedRandom) Pick() (id string, callback func() error)
Pick using weighted random to choose test returns a test.
func (*WeightedRandom) Run ¶
func (c *WeightedRandom) Run() error
Run using weighted random to choose test and execute the callback of the test.
type WeightedRandomTest ¶
type WeightedRandomTest struct { ID string // Required Weight float64 // Optional Callback func() error // Optional // contains filtered or unexported fields }
WeightedRandomTest is a test data for weighted random strategy.