You are here

function background_process_service_group_round_robin in Background Process 7.2

Same name and namespace in other branches
  1. 8 background_process.module \background_process_service_group_round_robin()
  2. 6 background_process.module \background_process_service_group_round_robin()
  3. 7 background_process.module \background_process_service_group_round_robin()

Round-robin load balancing based on random pick.

1 call to background_process_service_group_round_robin()
background_process_service_group_idle in ./background_process.module
Load balancing based on most idle clients.
1 string reference to 'background_process_service_group_round_robin'
background_process_get_service_groups in ./background_process.module
Get service hosts defined in the system.

File

./background_process.module, line 454

Code

function background_process_service_group_round_robin($service_group) {
  static $idx = NULL;
  if (isset($idx)) {
    $idx = ($idx + 1) % count($service_group['hosts']);
  }
  else {
    $idx = rand(0, count($service_group['hosts']) - 1);
  }
  return $service_group['hosts'][$idx];
}