Esempio n. 1
0
 /**
  * 获取APS_Client
  *
  * @param  string $service_name 服务名称
  * @return APS_Client
  */
 public function get_aps_client($service_name)
 {
     if (!isset($this->aps_clients[$service_name])) {
         $file = APS_Functions::get_config_file();
         $config = APF::get_instance()->get_config($service_name, $file);
         APF::get_instance()->debug($config['client']);
         $this->aps_clients[$service_name] = new APS_Client($this->get_zmq_context(), $config['client']);
     }
     return $this->aps_clients[$service_name];
 }
Esempio n. 2
0
 /**
  * 获取结果
  *
  * @param  integer $sequence 序号
  * @param  boolean $keep     是否保留结果
  * @return mixed
  */
 public function fetch_reply($sequence, $keep = FALSE, &$from_zmq = NULL)
 {
     if (isset($this->replies[$sequence])) {
         APF::get_instance()->debug($sequence);
         //zmq 请求 debug 信息
         // 从ZMQ中获取结果
         $rs = $this->replies[$sequence];
         $from_zmq = TRUE;
     } else {
         // 请求失败,走同步流程
         $rs = array(APS_Functions::aps_fetch_reply($this->requests[$sequence][0], $this->requests[$sequence][1]), 101);
         $from_zmq = FALSE;
     }
     if (!$keep) {
         unset($this->requests[$sequence]);
         unset($this->replies[$sequence]);
     }
     return $rs;
 }