Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AudienceAim ¶
type AudienceAim interface {
// contains filtered or unexported methods
}
AudienceAim is something that determines the audience that should be shown the experiment.
func AimPercent ¶
func AimPercent(n int) AudienceAim
AimPercent will randomly show the experiment to n % of the visitors.
func AimStrategy ¶
func AimStrategy(id string, fn func(Visitor) Params) AudienceAim
AimStrategy will show the experiment to the visitor if the given strategy determines it is ok to show it. A callback function can be given to return the Params to call the strategy based on the visitor.
func And ¶
func And(aims ...AudienceAim) AudienceAim
And will show the experiment if all of the aims will show the experiment.
func Or ¶
func Or(aims ...AudienceAim) AudienceAim
Or shows the experiment if one or more of the aims will show the experiment.
type Experiment ¶
type Experiment interface {
// Aim defines a restriction over the audience that will be shown this experiment.
Aim(AudienceAim) Experiment
}
Experiment is a single experiment that wants to be run.
type Lab ¶
type Lab interface {
// DefineStrategy defines strategies to aim at visitors.
DefineStrategy(string, Strategy)
// Experiment defines an experiment or retrieves one that already exists.
Experiment(string) Experiment
// Session starts a new session for the given visitor.
Session(Visitor) Session
}
Lab is a playground where you can define experiments and strategies.
type Params ¶
type Params map[string]interface{}
Params will hold all the parameters to call a strategy.
type Session ¶
type Session interface {
// Launch will run the given function for the given experiment ID only if the
// visitor is a target of the experiment. Will return as well a boolean to report
// if the visitor was shown the experiment.
Launch(string, func()) bool
}
Session is a single session for a visitor.
type StrategyGetter ¶
type StrategyGetter interface {
// Strategy returns the Strategy for the given ID.
Strategy(string) (Strategy, bool)
}
StrategyGetter will retrieve strategies based on their ID.
