Пример #1
0
 public static function write($topic, $level, $name, $log, $trace)
 {
     $trace = static::formatTrace($trace);
     $message = json_encode(['name' => $name, 'log' => $log, 'level' => $level, 'trace' => json_encode($trace), 'request' => $_SERVER, 'time' => date("Y-m-d H:i:s", time())], JSON_UNESCAPED_UNICODE);
     d($topic);
     d($message);
     return ZKafka::produce($topic, $message);
 }
Пример #2
0
 public function actionSetoffset()
 {
     $offset = ZKafka::getOffset(ZKafka::KAFKA_ERROR_OFFSET);
     d($offset);
     $ret = ZKafka::setOffset(ZKafka::KAFKA_ERROR_OFFSET, --$offset);
     d($ret);
     $offset = ZKafka::getOffset(ZKafka::KAFKA_ERROR_OFFSET);
     d($offset);
 }
Пример #3
0
 public static function process($topic, $offset, $limit = 20)
 {
     $message = ZKafka::consume($topic, $offset, $limit);
     return $message;
 }