You are here

function background_process_service_group_round_robin in Background Process 7

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.2 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_ass_service_group_idle in background_process_ass/background_process_ass.module
Determine host with most idle workers and claim it.
2 string references to 'background_process_service_group_round_robin'
BackgroundProcess::determineServiceHost in ./BackgroundProcess.class.php
background_process_get_service_groups in ./background_process.module
Get service hosts defined in the system.

File

./background_process.module, line 236

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];
}