Documentation
¶
Overview ¶
Package splittest holds the pure rules of app split testing: variant validation, sticky assignment and the env defaults. Ingress and the API both import it, so it stays free of store and HTTP types.
Index ¶
Constants ¶
const ( EnvCookieName = "APP_SPLIT_COOKIE_NAME" EnvCookieTTL = "APP_SPLIT_COOKIE_TTL" EnvOverrideParam = "APP_SPLIT_OVERRIDE_PARAM" EnvFlushInterval = "APP_SPLIT_FLUSH_INTERVAL" )
Env vars that tune the defaults a test can override per cookie.
const ( // MaxVariants bounds a test so the variants table stays readable. MaxVariants = 5 // TotalWeight is what the variant weights must add up to. TotalWeight = 100 )
const ( KindProduction = "production" KindBranch = "branch" KindRelease = "release" )
Variant kinds. Production is the app itself; the others are other deploys.
const ( StatusRunning = "running" StatusStopped = "stopped" )
Test statuses.
Variables ¶
This section is empty.
Functions ¶
func ValidCookieName ¶
ValidCookieName reports whether n is safe as a cookie or query parameter name.
Types ¶
type Assignment ¶
type Assignment struct {
Variant Variant
// SetCookie is true when the visitor's cookie must be written: a fresh
// draw or a QA override. A kept assignment leaves the cookie alone.
SetCookie bool
}
Assignment is the outcome of Decide.
func Decide ¶
func Decide(vs []Variant, forced, cookie string, rng *rand.Rand) Assignment
Decide picks the variant for one visitor. A forced key (the QA override) wins, then a still-valid cookie value, then a fresh weighted draw. A cookie naming a removed or zero-weight variant is treated as absent.
type Defaults ¶
type Defaults struct {
CookieName string
CookieTTL time.Duration
OverrideParam string
FlushInterval time.Duration
}
Defaults are the process-wide fallbacks for a test's cookie settings.
func DefaultsFromEnv ¶
DefaultsFromEnv reads the APP_SPLIT_* env vars over the built-in defaults.
type Variant ¶
type Variant struct {
ID string `json:"id"`
Label string `json:"label"`
Kind string `json:"kind"`
Ref string `json:"ref,omitempty"`
Weight int `json:"weight"`
}
Variant is one arm of a split test. Ref is a branch name for a branch variant and a deploy URL service name for a release variant.