function recv($msg) { /* 切换logid. */ cy_log_id_renew(); if (call_user_func($this->callback, $msg->body)) { $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); } /* 统计本次请求的时间 */ cy_stat_flush(); gc_collect_cycles(); }
function request_shutdown() { cy_stat_flush(); }
/** * 记录接口调用的所花的时间 * * $example cy_stat(__CLASS__.':'.__FUNCTION__, 5000); * * $param string $key key of interface. * $param int $elapdwset_elapsed * $param array $options options maybe errno, args.. etc. */ function cy_stat($key, $elapsed, $options = array()) { if (empty($_ENV['stat'][$key])) { $_ENV['stat'][$key] = array(); $_ENV['stat_count'] = 0; $_ENV['stat_flush_times'] = 0; } /* errno === 0 时不写,减少日志大小 if(empty($options['errno'])) { $options['errno'] = 0; } */ $_ENV['stat_count']++; $_ENV['stat'][$key]['c'][] = (int) $elapsed; empty($options) || ($_ENV['stat'][$key]['o'][] = $options); if ($_ENV['stat_count'] === $_ENV['config']['stat_max_line']) { cy_stat_flush(); } }
function recv($envelope) { /* 切换logid. */ cy_log_id_renew(); if (call_user_func($this->callback, $envelope->getBody())) { $this->queue->ack($envelope->getDeliveryTag()); } else { $this->queue->nack($envelope->getDeliveryTag(), AMQP_REQUEUE); } /* 统计本次请求的时间 */ cy_stat_flush(); gc_collect_cycles(); }