Пример #1
0
 public function getInstances($group = null)
 {
     $ret = array();
     $servers = Kwf_Util_Gearman_Servers::getServersTryConnect($group);
     foreach (array_keys($servers['jobServers']) as $key) {
         $ret[$key] = self::getInstance($key, $group);
     }
     return $ret;
 }
Пример #2
0
 /**
  * @return self
  */
 public static function createInstance($group = null)
 {
     $i = new self();
     $c = Kwf_Util_Gearman_Servers::getServersTryConnect($group);
     $i->_functionPrefix = $c['functionPrefix'];
     foreach ($c['jobServers'] as $server) {
         $i->addServer($server['host'], $server['port']);
     }
     return $i;
 }
Пример #3
0
 /**
  * @return self
  */
 public static function getInstanceCached($group = null)
 {
     static $i = array();
     if (!isset($i[$group])) {
         $i[$group] = new self();
         $c = Kwf_Util_Gearman_Servers::getServersCached($group);
         $i[$group]->_functionPrefix = $c['functionPrefix'];
         shuffle($c['jobServers']);
         foreach ($c['jobServers'] as $server) {
             $i[$group]->addServer($server['host'], $server['port']);
         }
     }
     return $i[$group];
 }