protected function launchWorkers($address = null)
{
$config = $this->config();
//Wheter this service does not implement payload router interface
if (!in_array('Scalr\\System\\Zmq\\Cron\\PayloadRouterInterface', class_implements($this->payloadClass))) {
return $this->_launchWorkers($address);
}
$numberWorkers = 0;
//It launches different pools of workers according to replication schema defined in the config
foreach (array_merge(!empty($config->replicate['type']) ? $config->replicate['type'] : [], ['all']) as $type) {
//It is possible to provide the number of the workers for each service
$pool = null;
if (is_array($type)) {
@(list($type, $pool) = $type);
$pool = $pool ?: intval($pool);
}
if (!empty($config->replicate['account'])) {
foreach ($config->replicate['account'] as $acc) {
$pool2 = null;
if (is_array($acc)) {
@(list($acc, $pool2) = $acc);
$pool2 = $pool2 ?: intval($pool2);
}
$numberWorkers += $this->_launchWorkers($this->name . '.' . $type . '.' . $acc, max($pool, $pool2));
}
}
$numberWorkers += $this->_launchWorkers($this->name . '.' . $type . '.all', $pool);
}
return $numberWorkers;
}