New creates a new experiment with the given name and sets the values that can enable it.
(xName string, config *ast.TaskRC, allowedValues ...int)
| 17 | // New creates a new experiment with the given name and sets the values that can |
| 18 | // enable it. |
| 19 | func New(xName string, config *ast.TaskRC, allowedValues ...int) Experiment { |
| 20 | var value int |
| 21 | if config != nil { |
| 22 | value = config.Experiments[xName] |
| 23 | } |
| 24 | |
| 25 | if value == 0 { |
| 26 | value, _ = strconv.Atoi(getEnv(xName)) |
| 27 | } |
| 28 | |
| 29 | x := Experiment{ |
| 30 | Name: xName, |
| 31 | AllowedValues: allowedValues, |
| 32 | Value: value, |
| 33 | } |
| 34 | xList = append(xList, x) |
| 35 | return x |
| 36 | } |
| 37 | |
| 38 | func (x Experiment) Enabled() bool { |
| 39 | return slices.Contains(x.AllowedValues, x.Value) |