Documentation ¶
Overview ¶
Package deterministic is used to make deterministic choices for users.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeChoice ¶
func MakeChoice(userID int64, choices ...interface{}) interface{}
MakeChoice makes a choice for the given user ID. This choice is deterministic given constant inputs.
Types ¶
type WeightedChoice ¶
type WeightedChoice interface {
Weight() int
}
A WeightedChoice represents some choice with an associated weight.
func MakeWeightedChoice ¶
func MakeWeightedChoice(userID int64, choices []WeightedChoice) WeightedChoice
MakeWeightedChoice makes a choice for the given user ID. This choice is deterministic given constant inputs.
To ensure proper distribution of users according to the weights, the following must be true:
(1) The sum of the weights must be less than the maximum assigned user ID. (2) User IDs must be evenly distributed across their range.
Click to show internal directories.
Click to hide internal directories.