Class: Gitlab::Experiment::Rollout::RoundRobin

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab/experiment/rollout/round_robin.rb

Constant Summary collapse

KEY_NAME =
:last_round_robin_variant

Instance Attribute Summary

Attributes inherited from Base

#experiment

Instance Method Summary collapse

Methods inherited from Base

#initialize, #rollout_for

Constructor Details

This class inherits a constructor from Gitlab::Experiment::Rollout::Base

Instance Method Details

#executeObject

Requires a cache to be configured.

Keeps track of the number of assignments into the experiment group, and uses this to rotate “round robin” style through the variants that are defined.

Relatively performant, but requires a cache, and is dependent on the performance of that cache store.



17
18
19
# File 'lib/gitlab/experiment/rollout/round_robin.rb', line 17

def execute
  variant_names[(cache.attr_inc(KEY_NAME) - 1) % variant_names.size]
end