diff --git a/carrera-sdk/consumer/php/composer.json b/carrera-sdk/consumer/php/composer.json new file mode 100644 index 0000000..48c985c --- /dev/null +++ b/carrera-sdk/consumer/php/composer.json @@ -0,0 +1,24 @@ +{ + "description": "The CodeIgniter framework", + "name": "codeigniter/framework", + "type": "project", + "homepage": "https://codeigniter.com", + "license": "MIT", + "support": { + "forum": "http://forum.codeigniter.com/", + "wiki": "https://github.com/bcit-ci/CodeIgniter/wiki", + "slack": "https://codeigniterchat.slack.com", + "source": "https://github.com/bcit-ci/CodeIgniter" + }, + "require": { + "php": ">=5.3.7", + "packaged/thrift": "^0.11.0" + }, + "suggest": { + "paragonie/random_compat": "Provides better randomness in PHP 5.x" + }, + "require-dev": { + "mikey179/vfsStream": "1.1.*", + "phpunit/phpunit": "4.* || 5.*" + } +} diff --git a/carrera-sdk/consumer/php/config/development/config_carrera_cluster.php b/carrera-sdk/consumer/php/config/development/config_carrera_cluster.php new file mode 100644 index 0000000..93856cf --- /dev/null +++ b/carrera-sdk/consumer/php/config/development/config_carrera_cluster.php @@ -0,0 +1,12 @@ + array('127.0.0.1:9713'), + // time out for each send from proxy to mq broker + 'CARRERA_PROXY_TIMEOUT' => 50, + // time out for each send from client to proxy + 'CARRERA_CLIENT_TIMEOUT' => 1000, + // log path + 'CARRERA_CLIENT_LOGPATH' => '/home/xiaoju/webroot/log/mq/', +); \ No newline at end of file diff --git a/carrera-sdk/consumer/php/config/production/config_carrera_cluster.php b/carrera-sdk/consumer/php/config/production/config_carrera_cluster.php new file mode 100644 index 0000000..93856cf --- /dev/null +++ b/carrera-sdk/consumer/php/config/production/config_carrera_cluster.php @@ -0,0 +1,12 @@ + array('127.0.0.1:9713'), + // time out for each send from proxy to mq broker + 'CARRERA_PROXY_TIMEOUT' => 50, + // time out for each send from client to proxy + 'CARRERA_CLIENT_TIMEOUT' => 1000, + // log path + 'CARRERA_CLIENT_LOGPATH' => '/home/xiaoju/webroot/log/mq/', +); \ No newline at end of file diff --git a/carrera-sdk/consumer/php/controllers/test/TestCarrera.php b/carrera-sdk/consumer/php/controllers/test/TestCarrera.php new file mode 100644 index 0000000..42b83e6 --- /dev/null +++ b/carrera-sdk/consumer/php/controllers/test/TestCarrera.php @@ -0,0 +1,38 @@ +load->library('carrera/Carrera'); + $ret = $this->carrera->pull('cg_1', 'Test'); + if ($ret['code'] > 0) { + var_dump($ret); + return; + } + $context = $ret['ret']['context']; + $messages = $ret['ret']['messages']; + $aSuccessOffsets = []; + $aFailOffsets = []; + foreach ($messages as $message) { + if ($this->callback($message->value)) { + $aSuccessOffsets[] = $message->offset; + } else { + $aFailOffsets[] = $message->offset; + } + } + $ret = $this->carrera->submit($context, $aSuccessOffsets, $aFailOffsets); + var_dump($ret); + } + + private function callback($value) { + echo "msg: ".$value."\r\n"; + return (mt_rand(1,100) > 50); + } +} \ No newline at end of file diff --git a/carrera-sdk/consumer/php/libraries/carrera/Carrera.php b/carrera-sdk/consumer/php/libraries/carrera/Carrera.php new file mode 100644 index 0000000..f2151f2 --- /dev/null +++ b/carrera-sdk/consumer/php/libraries/carrera/Carrera.php @@ -0,0 +1,521 @@ +load->config('config_carrera_cluster', true); + $aConfig = $ci->config->item('carrera', 'config_carrera_cluster'); + $this->proxyList = $aConfig['CARRERA_PROXY_LIST']; + $this->proxyTimeout = $aConfig['CARRERA_PROXY_TIMEOUT']; + $this->clientTimeout = $aConfig['CARRERA_CLIENT_TIMEOUT']; + $this->log_path = $aConfig['CARRERA_CLIENT_LOGPATH']; + } + + public function pull($sGroupId, $sTopic, $iMaxBatchSize = null, $iMaxLingerTime = null, $oResult = null) + { + $dropInfo = array( + 'opera_stat_key' => 'carrera_drop', + 'groupId' => $sGroupId, + 'topic' => $sTopic, + 'maxBatchSize' => $iMaxBatchSize, + 'maxLingerTime' => $iMaxLingerTime, + 'result' => $oResult, + 'version' => self::PHP_SDK_VERSION + ); + + if (!isset($sGroupId) || !isset($sTopic)) { + return array( + 'code' => self::MISSING_PARAMETERS, + 'msg' => 'missing parameters' + ); + } + if (!isset($iMaxBatchSize) || !isset($iMaxLingerTime)) { + $iMaxBatchSize = self::MAX_BATCH_SIZE; + $iMaxLingerTime = self::MAX_LINGER_TIME; + } + + $request = new PullRequest(array( + 'groupId' => $sGroupId, + 'topic' => $sTopic, + 'maxBatchSize' => $iMaxBatchSize, + 'maxLingerTime' => $iMaxLingerTime, + 'result' => $oResult, + 'version' => self::PHP_SDK_VERSION + )); + + $startTime = microtime(true); + + $retryCount = 0; + do { + try { + $this->proxyLocked = true; + $ret = $this->pullWithThrift('pull', $request); + switch ($ret['code']) { + case self::OK: + $status = 'success'; + break; + case self::CACHE_OK: + $status = 'cache_ok'; + break; + default: + $status = 'failure'; + break; + } + } catch (\Exception $e) { + $this->proxyLocked = false; + $ret = array( + 'code' => self::CLIENT_EXCEPTION, + 'msg' => $e->getMessage(), + ); + $status = 'failure'; + sleep(self::RETRY_INTERVAL); + } + } while ($retryCount++ < $this->clientRetry); + + $used = (microtime(true) - $startTime) * 1000; + $addr = isset($ret['ip']) ? $ret['ip'] : ''; + + $logInfo = array( + 'opera_stat_key' => 'carrera_trace', + 'result' => $status, + 'errno' => $ret['code'], + 'errmsg' => $ret['msg'], + 'ip' => $addr, + 'groupId' => $sGroupId, + 'topic' => $sTopic, + 'maxBatchSize' => $iMaxBatchSize, + 'maxLingerTime' => $iMaxLingerTime, + 'used' => $used, + 'version' => self::PHP_SDK_VERSION + ); + + if ($ret['code'] > self::CACHE_OK) { + $dropInfo['errno'] = $ret['code']; + $dropInfo['errmsg'] = $ret['msg']; + $this->writeLog($this->log_path . self::DROP_LOG, $dropInfo); + } + $this->writeLog($this->log_path . self::REQ_LOG, $logInfo); + + return $ret; + } + + public function fetch($sGroupId, $sConsumerId, $iMaxBatchSize = null, $iMaxLingerTime = null, array $oOffset = []) + { + $dropInfo = array( + 'opera_stat_key' => 'carrera_drop', + 'groupId' => $sGroupId, + 'consumerId' => $sConsumerId, + 'maxBatchSize' => $iMaxBatchSize, + 'maxLingerTime' => $iMaxLingerTime, + 'fetchOffset' => $oOffset, + 'version' => self::PHP_SDK_VERSION + ); + + if (!isset($sGroupId) || !isset($sConsumerId)) { + return array( + 'code' => self::MISSING_PARAMETERS, + 'msg' => 'missing parameters' + ); + } + if (!isset($iMaxBatchSize) || !isset($iMaxLingerTime)) { + $iMaxBatchSize = self::MAX_BATCH_SIZE; + $iMaxLingerTime = self::MAX_LINGER_TIME; + } + + $request = new FetchRequest(array( + 'consumerId' => $sConsumerId, + 'groupId' => $sGroupId, + 'fetchOffset' => $oOffset, + 'maxBatchSize' => $iMaxBatchSize, + 'maxLingerTime' => $iMaxLingerTime, + 'cluster' => $this->cluster, + 'version' => self::PHP_SDK_VERSION + )); + + $startTime = microtime(true); + try { + $this->proxyLocked = true; + $ret = $this->pullWithThrift('fetch', $request); + switch ($ret['code']) { + case self::OK: + $status = 'success'; + break; + case self::CACHE_OK: + $status = 'cache_ok'; + break; + default: + $status = 'failure'; + break; + } + } catch (\Exception $e) { + $this->proxyLocked = false; + $ret = array( + 'code' => self::CLIENT_EXCEPTION, + 'msg' => $e->getMessage(), + ); + $status = 'failure'; + } + $used = (microtime(true) - $startTime) * 1000; + $addr = $ret['ip']; + + $logInfo = array( + 'opera_stat_key' => 'carrera_trace', + 'result' => $status, + 'errno' => $ret['code'], + 'errmsg' => $ret['msg'], + 'ip' => $addr, + 'groupId' => $sGroupId, + 'consumerId' => $sConsumerId, + 'cluster' => $this->cluster, + 'maxBatchSize' => $iMaxBatchSize, + 'maxLingerTime' => $iMaxLingerTime, + 'used' => $used, + 'version' => self::PHP_SDK_VERSION + ); + + if ($ret['code'] > self::CACHE_OK) { + $dropInfo['errno'] = $ret['code']; + $dropInfo['errmsg'] = $ret['msg']; + $this->writeLog($this->log_path . self::DROP_LOG, $dropInfo); + } + $this->writeLog($this->log_path . self::REQ_LOG, $logInfo); + + return $ret; + } + + public function ack($sGroupId, $sConsumerId, array $oOffsets = []) + { + $dropInfo = array( + 'opera_stat_key' => 'carrera_drop', + 'groupId' => $sGroupId, + 'consumerId' => $sConsumerId, + 'cluster' => $this->cluster, + 'offsets' => $oOffsets + ); + + if (!isset($sGroupId) || !isset($sConsumerId)) { + return array( + 'code' => self::MISSING_PARAMETERS, + 'msg' => 'missing parameters' + ); + } + + $request = new AckResult(array( + 'consumerId' => $sConsumerId, + 'groupId' => $sGroupId, + 'cluster' => $this->cluster, + 'offsets' => $oOffsets, + )); + + $startTime = microtime(true); + try { + $ret = $this->pullWithThrift('ack', $request); + switch ($ret['code']) { + case self::OK: + $status = 'success'; + break; + case self::CACHE_OK: + $status = 'cache_ok'; + break; + default: + $status = 'failure'; + break; + } + } catch (\Exception $e) { + $ret = array( + 'code' => self::CLIENT_EXCEPTION, + 'msg' => $e->getMessage(), + ); + $status = 'failure'; + } + $this->proxyLocked = false; + $used = (microtime(true) - $startTime) * 1000; + $addr = $ret['ip']; + + $logInfo = array( + 'opera_stat_key' => 'carrera_trace', + 'result' => $status, + 'errno' => $ret['code'], + 'errmsg' => $ret['msg'], + 'ip' => $addr, + 'groupId' => $sGroupId, + 'consumerId' => $sConsumerId, + 'cluster' => $this->cluster, + 'used' => $used + ); + + if ($ret['code'] > self::CACHE_OK) { + $dropInfo['errno'] = $ret['code']; + $dropInfo['errmsg'] = $ret['msg']; + $this->writeLog($this->log_path . self::DROP_LOG, $dropInfo); + } + $this->writeLog($this->log_path . self::REQ_LOG, $logInfo); + + return $ret; + } + + public function submit($oContext, array $aSuccessOffsets, array $aFailOffsets, $oNextResult = null) + { + $dropInfo = array( + 'opera_stat_key' => 'carrera_drop', + 'context' => $oContext, + 'nextResult' => $oNextResult, + ); + + if (!isset($oContext) || !isset($aSuccessOffsets) || !isset($aFailOffsets)) { + return array( + 'code' => self::MISSING_PARAMETERS, + 'msg' => 'missing parameters' + ); + } + + $request = new ConsumeResult(array( + 'context' => $oContext, + 'successOffsets' => $aSuccessOffsets, + 'failOffsets' => $aFailOffsets, + 'nextResult' => $oNextResult + )); + + $startTime = microtime(true); + try { + $ret = $this->pullWithThrift('submit', $request); + switch ($ret['code']) { + case self::OK: + $status = 'success'; + break; + case self::CACHE_OK: + $status = 'cache_ok'; + break; + default: + $status = 'failure'; + break; + } + } catch (\Exception $e) { + $ret = array( + 'code' => self::CLIENT_EXCEPTION, + 'msg' => $e->getMessage(), + ); + $status = 'failure'; + } + $this->proxyLocked = false; + $used = (microtime(true) - $startTime) * 1000; + $addr = $ret['ip']; + + $logInfo = array( + 'opera_stat_key' => 'carrera_trace', + 'result' => $status, + 'errno' => $ret['code'], + 'errmsg' => $ret['msg'], + 'ip' => $addr, + 'used' => $used + ); + + if ($ret['code'] > self::CACHE_OK) { + $dropInfo['errno'] = $ret['code']; + $dropInfo['errmsg'] = $ret['msg']; + $this->writeLog($this->log_path . self::DROP_LOG, $dropInfo); + } + $this->writeLog($this->log_path . self::REQ_LOG, $logInfo); + + return $ret; + } + + private function pullWithThrift($cmd, $request) + { + static $proxyAddr; + + $tmpProxyList = $this->proxyList; + if (!$proxyAddr) { + $proxyIndex = array_rand($tmpProxyList, 1); + $proxyAddr = $tmpProxyList[$proxyIndex]; + } + + $retryCount = 0; + do { + try { + if ($retryCount > 1) { + if (!$this->proxyLocked) { + if (count($tmpProxyList) <= 1) { + $tmpProxyList = $this->proxyList; + } else { + $rmProxyIndex = array_search($proxyAddr, $tmpProxyList); + unset($tmpProxyList[$rmProxyIndex]); + } + $proxyIndex = array_rand($tmpProxyList, 1); + $proxyAddr = $tmpProxyList[$proxyIndex]; + } + } + + list($hostname, $port) = explode(':', $proxyAddr); + $socket = new TSocket($hostname, $port); + $socket->setSendTimeout($this->clientTimeout); + $socket->setRecvTimeout($this->clientTimeout); + $transport = new TFramedTransport($socket); + $transport->open(); + $protocol = new TCompactProtocol($transport); + $client = new ConsumerServiceClient($protocol); + + $response = $client->$cmd($request); + $transport->close(); + + switch ($cmd) { + case 'pull': + if ($response instanceof PullResponse) { + if ($response->context->qid) { + $ret = [ + 'context' => $response->context, + 'messages' => $response->messages + ]; + $result = array( + 'ret' => $ret, + 'code' => self::OK, + 'msg' => 'success', + 'ip' => $proxyAddr + ); + return $result; + } elseif ($retryCount > 1) { + $result = array( + 'ret' => null, + 'code' => self::EMPTY_RET, + 'msg' => 'empty', + 'ip' => $proxyAddr + ); + return $result; + } + } + break; + default: + if ($response !== null) { + $result = array( + 'ret' => $response, + 'code' => self::OK, + 'msg' => 'success', + 'ip' => $proxyAddr + ); + return $result; + } + break; + } + $result = array( + 'code' => self::CLIENT_EXCEPTION, + 'msg' => 'failure', + 'ip' => $proxyAddr + ); + sleep(self::RETRY_INTERVAL); + } catch (PullException $e) { + if (isset($transport)) { + $transport->close(); + } + $result = array( + 'code' => self::CLIENT_EXCEPTION, + 'msg' => $e->getMessage(), + 'ip' => $proxyAddr + ); + } + } while ($retryCount++ < $this->clientRetry); + + return $result; + } + + /** + * 写日志 + * + * @param $sPath string 日志文件路径 + * @param @xLog mixed 日志信息 + * + * @return void + */ + private function writeLog($sPath, $mLog) + { + if (file_exists(dirname($sPath))) { + if (is_array($mLog)) { + $sMsg = json_encode($mLog); + } else { + $sMsg = (string)$mLog; + } + $sLine = sprintf(self::LOG_FORMAT, date('Y-m-d H:i:s'), $sMsg); + $rFp = fopen($sPath, 'a+'); + fwrite($rFp, $sLine . "\n"); + fclose($rFp); + } + } +} \ No newline at end of file diff --git a/carrera-sdk/consumer/php/libraries/carrera/Thrift/ConsumerService.php b/carrera-sdk/consumer/php/libraries/carrera/Thrift/ConsumerService.php new file mode 100644 index 0000000..c1e8f12 --- /dev/null +++ b/carrera-sdk/consumer/php/libraries/carrera/Thrift/ConsumerService.php @@ -0,0 +1,1352 @@ +input_ = $input; + $this->output_ = $output ? $output : $input; + } + + public function pull(\didi\carrera\consumer\proxy\PullRequest $request) + { + $this->send_pull($request); + return $this->recv_pull(); + } + + public function send_pull(\didi\carrera\consumer\proxy\PullRequest $request) + { + $args = new \didi\carrera\consumer\proxy\ConsumerService_pull_args(); + $args->request = $request; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'pull', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('pull', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_pull() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\didi\carrera\consumer\proxy\ConsumerService_pull_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \didi\carrera\consumer\proxy\ConsumerService_pull_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + if ($result->error !== null) { + throw $result->error; + } + throw new \Exception("pull failed: unknown result"); + } + + public function submit(\didi\carrera\consumer\proxy\ConsumeResult $result) + { + $this->send_submit($result); + return $this->recv_submit(); + } + + public function send_submit(\didi\carrera\consumer\proxy\ConsumeResult $result) + { + $args = new \didi\carrera\consumer\proxy\ConsumerService_submit_args(); + $args->result = $result; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'submit', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('submit', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_submit() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\didi\carrera\consumer\proxy\ConsumerService_submit_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \didi\carrera\consumer\proxy\ConsumerService_submit_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + if ($result->error !== null) { + throw $result->error; + } + throw new \Exception("submit failed: unknown result"); + } + + public function getConsumeStats(\didi\carrera\consumer\proxy\ConsumeStatsRequest $request) + { + $this->send_getConsumeStats($request); + return $this->recv_getConsumeStats(); + } + + public function send_getConsumeStats(\didi\carrera\consumer\proxy\ConsumeStatsRequest $request) + { + $args = new \didi\carrera\consumer\proxy\ConsumerService_getConsumeStats_args(); + $args->request = $request; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'getConsumeStats', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('getConsumeStats', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_getConsumeStats() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\didi\carrera\consumer\proxy\ConsumerService_getConsumeStats_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \didi\carrera\consumer\proxy\ConsumerService_getConsumeStats_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + if ($result->error !== null) { + throw $result->error; + } + throw new \Exception("getConsumeStats failed: unknown result"); + } + + public function fetch(\didi\carrera\consumer\proxy\FetchRequest $request) + { + $this->send_fetch($request); + return $this->recv_fetch(); + } + + public function send_fetch(\didi\carrera\consumer\proxy\FetchRequest $request) + { + $args = new \didi\carrera\consumer\proxy\ConsumerService_fetch_args(); + $args->request = $request; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'fetch', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('fetch', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_fetch() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\didi\carrera\consumer\proxy\ConsumerService_fetch_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \didi\carrera\consumer\proxy\ConsumerService_fetch_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + throw new \Exception("fetch failed: unknown result"); + } + + public function ack(\didi\carrera\consumer\proxy\AckResult $result) + { + $this->send_ack($result); + return $this->recv_ack(); + } + + public function send_ack(\didi\carrera\consumer\proxy\AckResult $result) + { + $args = new \didi\carrera\consumer\proxy\ConsumerService_ack_args(); + $args->result = $result; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'ack', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('ack', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_ack() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\didi\carrera\consumer\proxy\ConsumerService_ack_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \didi\carrera\consumer\proxy\ConsumerService_ack_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + throw new \Exception("ack failed: unknown result"); + } + +} + +// HELPER FUNCTIONS AND STRUCTURES + +class ConsumerService_pull_args { + static $_TSPEC; + + /** + * @var \didi\carrera\consumer\proxy\PullRequest + */ + public $request = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'request', + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\PullRequest', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['request'])) { + $this->request = $vals['request']; + } + } + } + + public function getName() { + return 'ConsumerService_pull_args'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRUCT) { + $this->request = new \didi\carrera\consumer\proxy\PullRequest(); + $xfer += $this->request->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ConsumerService_pull_args'); + if ($this->request !== null) { + if (!is_object($this->request)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('request', TType::STRUCT, 1); + $xfer += $this->request->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ConsumerService_pull_result { + static $_TSPEC; + + /** + * @var \didi\carrera\consumer\proxy\PullResponse + */ + public $success = null; + /** + * @var \didi\carrera\consumer\proxy\PullException + */ + public $error = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 0 => array( + 'var' => 'success', + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\PullResponse', + ), + 1 => array( + 'var' => 'error', + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\PullException', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['success'])) { + $this->success = $vals['success']; + } + if (isset($vals['error'])) { + $this->error = $vals['error']; + } + } + } + + public function getName() { + return 'ConsumerService_pull_result'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 0: + if ($ftype == TType::STRUCT) { + $this->success = new \didi\carrera\consumer\proxy\PullResponse(); + $xfer += $this->success->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + case 1: + if ($ftype == TType::STRUCT) { + $this->error = new \didi\carrera\consumer\proxy\PullException(); + $xfer += $this->error->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ConsumerService_pull_result'); + if ($this->success !== null) { + if (!is_object($this->success)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('success', TType::STRUCT, 0); + $xfer += $this->success->write($output); + $xfer += $output->writeFieldEnd(); + } + if ($this->error !== null) { + $xfer += $output->writeFieldBegin('error', TType::STRUCT, 1); + $xfer += $this->error->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ConsumerService_submit_args { + static $_TSPEC; + + /** + * @var \didi\carrera\consumer\proxy\ConsumeResult + */ + public $result = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'result', + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\ConsumeResult', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['result'])) { + $this->result = $vals['result']; + } + } + } + + public function getName() { + return 'ConsumerService_submit_args'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRUCT) { + $this->result = new \didi\carrera\consumer\proxy\ConsumeResult(); + $xfer += $this->result->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ConsumerService_submit_args'); + if ($this->result !== null) { + if (!is_object($this->result)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('result', TType::STRUCT, 1); + $xfer += $this->result->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ConsumerService_submit_result { + static $_TSPEC; + + /** + * @var bool + */ + public $success = null; + /** + * @var \didi\carrera\consumer\proxy\PullException + */ + public $error = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 0 => array( + 'var' => 'success', + 'type' => TType::BOOL, + ), + 1 => array( + 'var' => 'error', + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\PullException', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['success'])) { + $this->success = $vals['success']; + } + if (isset($vals['error'])) { + $this->error = $vals['error']; + } + } + } + + public function getName() { + return 'ConsumerService_submit_result'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 0: + if ($ftype == TType::BOOL) { + $xfer += $input->readBool($this->success); + } else { + $xfer += $input->skip($ftype); + } + break; + case 1: + if ($ftype == TType::STRUCT) { + $this->error = new \didi\carrera\consumer\proxy\PullException(); + $xfer += $this->error->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ConsumerService_submit_result'); + if ($this->success !== null) { + $xfer += $output->writeFieldBegin('success', TType::BOOL, 0); + $xfer += $output->writeBool($this->success); + $xfer += $output->writeFieldEnd(); + } + if ($this->error !== null) { + $xfer += $output->writeFieldBegin('error', TType::STRUCT, 1); + $xfer += $this->error->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ConsumerService_getConsumeStats_args { + static $_TSPEC; + + /** + * @var \didi\carrera\consumer\proxy\ConsumeStatsRequest + */ + public $request = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'request', + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\ConsumeStatsRequest', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['request'])) { + $this->request = $vals['request']; + } + } + } + + public function getName() { + return 'ConsumerService_getConsumeStats_args'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRUCT) { + $this->request = new \didi\carrera\consumer\proxy\ConsumeStatsRequest(); + $xfer += $this->request->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ConsumerService_getConsumeStats_args'); + if ($this->request !== null) { + if (!is_object($this->request)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('request', TType::STRUCT, 1); + $xfer += $this->request->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ConsumerService_getConsumeStats_result { + static $_TSPEC; + + /** + * @var \didi\carrera\consumer\proxy\ConsumeStats[] + */ + public $success = null; + /** + * @var \didi\carrera\consumer\proxy\PullException + */ + public $error = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 0 => array( + 'var' => 'success', + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\ConsumeStats', + ), + ), + 1 => array( + 'var' => 'error', + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\PullException', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['success'])) { + $this->success = $vals['success']; + } + if (isset($vals['error'])) { + $this->error = $vals['error']; + } + } + } + + public function getName() { + return 'ConsumerService_getConsumeStats_result'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 0: + if ($ftype == TType::LST) { + $this->success = array(); + $_size98 = 0; + $_etype101 = 0; + $xfer += $input->readListBegin($_etype101, $_size98); + for ($_i102 = 0; $_i102 < $_size98; ++$_i102) + { + $elem103 = null; + $elem103 = new \didi\carrera\consumer\proxy\ConsumeStats(); + $xfer += $elem103->read($input); + $this->success []= $elem103; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + case 1: + if ($ftype == TType::STRUCT) { + $this->error = new \didi\carrera\consumer\proxy\PullException(); + $xfer += $this->error->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ConsumerService_getConsumeStats_result'); + if ($this->success !== null) { + if (!is_array($this->success)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('success', TType::LST, 0); + { + $output->writeListBegin(TType::STRUCT, count($this->success)); + { + foreach ($this->success as $iter104) + { + $xfer += $iter104->write($output); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } + if ($this->error !== null) { + $xfer += $output->writeFieldBegin('error', TType::STRUCT, 1); + $xfer += $this->error->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ConsumerService_fetch_args { + static $_TSPEC; + + /** + * @var \didi\carrera\consumer\proxy\FetchRequest + */ + public $request = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'request', + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\FetchRequest', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['request'])) { + $this->request = $vals['request']; + } + } + } + + public function getName() { + return 'ConsumerService_fetch_args'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRUCT) { + $this->request = new \didi\carrera\consumer\proxy\FetchRequest(); + $xfer += $this->request->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ConsumerService_fetch_args'); + if ($this->request !== null) { + if (!is_object($this->request)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('request', TType::STRUCT, 1); + $xfer += $this->request->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ConsumerService_fetch_result { + static $_TSPEC; + + /** + * @var \didi\carrera\consumer\proxy\FetchResponse + */ + public $success = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 0 => array( + 'var' => 'success', + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\FetchResponse', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['success'])) { + $this->success = $vals['success']; + } + } + } + + public function getName() { + return 'ConsumerService_fetch_result'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 0: + if ($ftype == TType::STRUCT) { + $this->success = new \didi\carrera\consumer\proxy\FetchResponse(); + $xfer += $this->success->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ConsumerService_fetch_result'); + if ($this->success !== null) { + if (!is_object($this->success)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('success', TType::STRUCT, 0); + $xfer += $this->success->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ConsumerService_ack_args { + static $_TSPEC; + + /** + * @var \didi\carrera\consumer\proxy\AckResult + */ + public $result = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'result', + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\AckResult', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['result'])) { + $this->result = $vals['result']; + } + } + } + + public function getName() { + return 'ConsumerService_ack_args'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRUCT) { + $this->result = new \didi\carrera\consumer\proxy\AckResult(); + $xfer += $this->result->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ConsumerService_ack_args'); + if ($this->result !== null) { + if (!is_object($this->result)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('result', TType::STRUCT, 1); + $xfer += $this->result->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ConsumerService_ack_result { + static $_TSPEC; + + /** + * @var bool + */ + public $success = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 0 => array( + 'var' => 'success', + 'type' => TType::BOOL, + ), + ); + } + if (is_array($vals)) { + if (isset($vals['success'])) { + $this->success = $vals['success']; + } + } + } + + public function getName() { + return 'ConsumerService_ack_result'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 0: + if ($ftype == TType::BOOL) { + $xfer += $input->readBool($this->success); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ConsumerService_ack_result'); + if ($this->success !== null) { + $xfer += $output->writeFieldBegin('success', TType::BOOL, 0); + $xfer += $output->writeBool($this->success); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ConsumerServiceProcessor { + protected $handler_ = null; + public function __construct($handler) { + $this->handler_ = $handler; + } + + public function process($input, $output) { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $input->readMessageBegin($fname, $mtype, $rseqid); + $methodname = 'process_'.$fname; + if (!method_exists($this, $methodname)) { + $input->skip(TType::STRUCT); + $input->readMessageEnd(); + $x = new TApplicationException('Function '.$fname.' not implemented.', TApplicationException::UNKNOWN_METHOD); + $output->writeMessageBegin($fname, TMessageType::EXCEPTION, $rseqid); + $x->write($output); + $output->writeMessageEnd(); + $output->getTransport()->flush(); + return; + } + $this->$methodname($rseqid, $input, $output); + return true; + } + + protected function process_pull($seqid, $input, $output) { + $args = new \didi\carrera\consumer\proxy\ConsumerService_pull_args(); + $args->read($input); + $input->readMessageEnd(); + $result = new \didi\carrera\consumer\proxy\ConsumerService_pull_result(); + try { + $result->success = $this->handler_->pull($args->request); + } catch (\didi\carrera\consumer\proxy\PullException $error) { + $result->error = $error; + } + $bin_accel = ($output instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($output, 'pull', TMessageType::REPLY, $result, $seqid, $output->isStrictWrite()); + } + else + { + $output->writeMessageBegin('pull', TMessageType::REPLY, $seqid); + $result->write($output); + $output->writeMessageEnd(); + $output->getTransport()->flush(); + } + } + protected function process_submit($seqid, $input, $output) { + $args = new \didi\carrera\consumer\proxy\ConsumerService_submit_args(); + $args->read($input); + $input->readMessageEnd(); + $result = new \didi\carrera\consumer\proxy\ConsumerService_submit_result(); + try { + $result->success = $this->handler_->submit($args->result); + } catch (\didi\carrera\consumer\proxy\PullException $error) { + $result->error = $error; + } + $bin_accel = ($output instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($output, 'submit', TMessageType::REPLY, $result, $seqid, $output->isStrictWrite()); + } + else + { + $output->writeMessageBegin('submit', TMessageType::REPLY, $seqid); + $result->write($output); + $output->writeMessageEnd(); + $output->getTransport()->flush(); + } + } + protected function process_getConsumeStats($seqid, $input, $output) { + $args = new \didi\carrera\consumer\proxy\ConsumerService_getConsumeStats_args(); + $args->read($input); + $input->readMessageEnd(); + $result = new \didi\carrera\consumer\proxy\ConsumerService_getConsumeStats_result(); + try { + $result->success = $this->handler_->getConsumeStats($args->request); + } catch (\didi\carrera\consumer\proxy\PullException $error) { + $result->error = $error; + } + $bin_accel = ($output instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($output, 'getConsumeStats', TMessageType::REPLY, $result, $seqid, $output->isStrictWrite()); + } + else + { + $output->writeMessageBegin('getConsumeStats', TMessageType::REPLY, $seqid); + $result->write($output); + $output->writeMessageEnd(); + $output->getTransport()->flush(); + } + } + protected function process_fetch($seqid, $input, $output) { + $args = new \didi\carrera\consumer\proxy\ConsumerService_fetch_args(); + $args->read($input); + $input->readMessageEnd(); + $result = new \didi\carrera\consumer\proxy\ConsumerService_fetch_result(); + $result->success = $this->handler_->fetch($args->request); + $bin_accel = ($output instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($output, 'fetch', TMessageType::REPLY, $result, $seqid, $output->isStrictWrite()); + } + else + { + $output->writeMessageBegin('fetch', TMessageType::REPLY, $seqid); + $result->write($output); + $output->writeMessageEnd(); + $output->getTransport()->flush(); + } + } + protected function process_ack($seqid, $input, $output) { + $args = new \didi\carrera\consumer\proxy\ConsumerService_ack_args(); + $args->read($input); + $input->readMessageEnd(); + $result = new \didi\carrera\consumer\proxy\ConsumerService_ack_result(); + $result->success = $this->handler_->ack($args->result); + $bin_accel = ($output instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($output, 'ack', TMessageType::REPLY, $result, $seqid, $output->isStrictWrite()); + } + else + { + $output->writeMessageBegin('ack', TMessageType::REPLY, $seqid); + $result->write($output); + $output->writeMessageEnd(); + $output->getTransport()->flush(); + } + } +} + diff --git a/carrera-sdk/consumer/php/libraries/carrera/Thrift/Types.php b/carrera-sdk/consumer/php/libraries/carrera/Thrift/Types.php new file mode 100644 index 0000000..dec5337 --- /dev/null +++ b/carrera-sdk/consumer/php/libraries/carrera/Thrift/Types.php @@ -0,0 +1,2090 @@ + array( + 'var' => 'key', + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'value', + 'type' => TType::STRING, + ), + 3 => array( + 'var' => 'tag', + 'type' => TType::STRING, + ), + 4 => array( + 'var' => 'offset', + 'type' => TType::I64, + ), + 5 => array( + 'var' => 'properties', + 'type' => TType::MAP, + 'ktype' => TType::STRING, + 'vtype' => TType::STRING, + 'key' => array( + 'type' => TType::STRING, + ), + 'val' => array( + 'type' => TType::STRING, + ), + ), + ); + } + if (is_array($vals)) { + if (isset($vals['key'])) { + $this->key = $vals['key']; + } + if (isset($vals['value'])) { + $this->value = $vals['value']; + } + if (isset($vals['tag'])) { + $this->tag = $vals['tag']; + } + if (isset($vals['offset'])) { + $this->offset = $vals['offset']; + } + if (isset($vals['properties'])) { + $this->properties = $vals['properties']; + } + } + } + + public function getName() { + return 'Message'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->key); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->value); + } else { + $xfer += $input->skip($ftype); + } + break; + case 3: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->tag); + } else { + $xfer += $input->skip($ftype); + } + break; + case 4: + if ($ftype == TType::I64) { + $xfer += $input->readI64($this->offset); + } else { + $xfer += $input->skip($ftype); + } + break; + case 5: + if ($ftype == TType::MAP) { + $this->properties = array(); + $_size0 = 0; + $_ktype1 = 0; + $_vtype2 = 0; + $xfer += $input->readMapBegin($_ktype1, $_vtype2, $_size0); + for ($_i4 = 0; $_i4 < $_size0; ++$_i4) + { + $key5 = ''; + $val6 = ''; + $xfer += $input->readString($key5); + $xfer += $input->readString($val6); + $this->properties[$key5] = $val6; + } + $xfer += $input->readMapEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('Message'); + if ($this->key !== null) { + $xfer += $output->writeFieldBegin('key', TType::STRING, 1); + $xfer += $output->writeString($this->key); + $xfer += $output->writeFieldEnd(); + } + if ($this->value !== null) { + $xfer += $output->writeFieldBegin('value', TType::STRING, 2); + $xfer += $output->writeString($this->value); + $xfer += $output->writeFieldEnd(); + } + if ($this->tag !== null) { + $xfer += $output->writeFieldBegin('tag', TType::STRING, 3); + $xfer += $output->writeString($this->tag); + $xfer += $output->writeFieldEnd(); + } + if ($this->offset !== null) { + $xfer += $output->writeFieldBegin('offset', TType::I64, 4); + $xfer += $output->writeI64($this->offset); + $xfer += $output->writeFieldEnd(); + } + if ($this->properties !== null) { + if (!is_array($this->properties)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('properties', TType::MAP, 5); + { + $output->writeMapBegin(TType::STRING, TType::STRING, count($this->properties)); + { + foreach ($this->properties as $kiter7 => $viter8) + { + $xfer += $output->writeString($kiter7); + $xfer += $output->writeString($viter8); + } + } + $output->writeMapEnd(); + } + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class Context { + static $_TSPEC; + + /** + * @var string + */ + public $groupId = null; + /** + * @var string + */ + public $topic = null; + /** + * @var string + */ + public $qid = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'groupId', + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'topic', + 'type' => TType::STRING, + ), + 3 => array( + 'var' => 'qid', + 'type' => TType::STRING, + ), + ); + } + if (is_array($vals)) { + if (isset($vals['groupId'])) { + $this->groupId = $vals['groupId']; + } + if (isset($vals['topic'])) { + $this->topic = $vals['topic']; + } + if (isset($vals['qid'])) { + $this->qid = $vals['qid']; + } + } + } + + public function getName() { + return 'Context'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->groupId); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->topic); + } else { + $xfer += $input->skip($ftype); + } + break; + case 3: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->qid); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('Context'); + if ($this->groupId !== null) { + $xfer += $output->writeFieldBegin('groupId', TType::STRING, 1); + $xfer += $output->writeString($this->groupId); + $xfer += $output->writeFieldEnd(); + } + if ($this->topic !== null) { + $xfer += $output->writeFieldBegin('topic', TType::STRING, 2); + $xfer += $output->writeString($this->topic); + $xfer += $output->writeFieldEnd(); + } + if ($this->qid !== null) { + $xfer += $output->writeFieldBegin('qid', TType::STRING, 3); + $xfer += $output->writeString($this->qid); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ConsumeResult { + static $_TSPEC; + + /** + * @var \didi\carrera\consumer\proxy\Context + */ + public $context = null; + /** + * @var int[] + */ + public $successOffsets = null; + /** + * @var int[] + */ + public $failOffsets = null; + /** + * @var \didi\carrera\consumer\proxy\ConsumeResult + */ + public $nextResult = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'context', + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\Context', + ), + 3 => array( + 'var' => 'successOffsets', + 'type' => TType::LST, + 'etype' => TType::I64, + 'elem' => array( + 'type' => TType::I64, + ), + ), + 4 => array( + 'var' => 'failOffsets', + 'type' => TType::LST, + 'etype' => TType::I64, + 'elem' => array( + 'type' => TType::I64, + ), + ), + 10 => array( + 'var' => 'nextResult', + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\ConsumeResult', + ), + ); + } + if (is_array($vals)) { + if (isset($vals['context'])) { + $this->context = $vals['context']; + } + if (isset($vals['successOffsets'])) { + $this->successOffsets = $vals['successOffsets']; + } + if (isset($vals['failOffsets'])) { + $this->failOffsets = $vals['failOffsets']; + } + if (isset($vals['nextResult'])) { + $this->nextResult = $vals['nextResult']; + } + } + } + + public function getName() { + return 'ConsumeResult'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRUCT) { + $this->context = new \didi\carrera\consumer\proxy\Context(); + $xfer += $this->context->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + case 3: + if ($ftype == TType::LST) { + $this->successOffsets = array(); + $_size9 = 0; + $_etype12 = 0; + $xfer += $input->readListBegin($_etype12, $_size9); + for ($_i13 = 0; $_i13 < $_size9; ++$_i13) + { + $elem14 = null; + $xfer += $input->readI64($elem14); + $this->successOffsets []= $elem14; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + case 4: + if ($ftype == TType::LST) { + $this->failOffsets = array(); + $_size15 = 0; + $_etype18 = 0; + $xfer += $input->readListBegin($_etype18, $_size15); + for ($_i19 = 0; $_i19 < $_size15; ++$_i19) + { + $elem20 = null; + $xfer += $input->readI64($elem20); + $this->failOffsets []= $elem20; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + case 10: + if ($ftype == TType::STRUCT) { + $this->nextResult = new \didi\carrera\consumer\proxy\ConsumeResult(); + $xfer += $this->nextResult->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ConsumeResult'); + if ($this->context !== null) { + if (!is_object($this->context)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('context', TType::STRUCT, 1); + $xfer += $this->context->write($output); + $xfer += $output->writeFieldEnd(); + } + if ($this->successOffsets !== null) { + if (!is_array($this->successOffsets)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('successOffsets', TType::LST, 3); + { + $output->writeListBegin(TType::I64, count($this->successOffsets)); + { + foreach ($this->successOffsets as $iter21) + { + $xfer += $output->writeI64($iter21); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } + if ($this->failOffsets !== null) { + if (!is_array($this->failOffsets)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('failOffsets', TType::LST, 4); + { + $output->writeListBegin(TType::I64, count($this->failOffsets)); + { + foreach ($this->failOffsets as $iter22) + { + $xfer += $output->writeI64($iter22); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } + if ($this->nextResult !== null) { + if (!is_object($this->nextResult)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('nextResult', TType::STRUCT, 10); + $xfer += $this->nextResult->write($output); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class PullRequest { + static $_TSPEC; + + /** + * @var string + */ + public $groupId = null; + /** + * @var string + */ + public $topic = null; + /** + * @var int + */ + public $maxBatchSize = null; + /** + * @var int + */ + public $maxLingerTime = null; + /** + * @var \didi\carrera\consumer\proxy\ConsumeResult + */ + public $result = null; + /** + * @var string + */ + public $version = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'groupId', + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'topic', + 'type' => TType::STRING, + ), + 10 => array( + 'var' => 'maxBatchSize', + 'type' => TType::I32, + ), + 11 => array( + 'var' => 'maxLingerTime', + 'type' => TType::I32, + ), + 50 => array( + 'var' => 'result', + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\ConsumeResult', + ), + 60 => array( + 'var' => 'version', + 'type' => TType::STRING, + ), + ); + } + if (is_array($vals)) { + if (isset($vals['groupId'])) { + $this->groupId = $vals['groupId']; + } + if (isset($vals['topic'])) { + $this->topic = $vals['topic']; + } + if (isset($vals['maxBatchSize'])) { + $this->maxBatchSize = $vals['maxBatchSize']; + } + if (isset($vals['maxLingerTime'])) { + $this->maxLingerTime = $vals['maxLingerTime']; + } + if (isset($vals['result'])) { + $this->result = $vals['result']; + } + if (isset($vals['version'])) { + $this->version = $vals['version']; + } + } + } + + public function getName() { + return 'PullRequest'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->groupId); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->topic); + } else { + $xfer += $input->skip($ftype); + } + break; + case 10: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->maxBatchSize); + } else { + $xfer += $input->skip($ftype); + } + break; + case 11: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->maxLingerTime); + } else { + $xfer += $input->skip($ftype); + } + break; + case 50: + if ($ftype == TType::STRUCT) { + $this->result = new \didi\carrera\consumer\proxy\ConsumeResult(); + $xfer += $this->result->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + case 60: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->version); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('PullRequest'); + if ($this->groupId !== null) { + $xfer += $output->writeFieldBegin('groupId', TType::STRING, 1); + $xfer += $output->writeString($this->groupId); + $xfer += $output->writeFieldEnd(); + } + if ($this->topic !== null) { + $xfer += $output->writeFieldBegin('topic', TType::STRING, 2); + $xfer += $output->writeString($this->topic); + $xfer += $output->writeFieldEnd(); + } + if ($this->maxBatchSize !== null) { + $xfer += $output->writeFieldBegin('maxBatchSize', TType::I32, 10); + $xfer += $output->writeI32($this->maxBatchSize); + $xfer += $output->writeFieldEnd(); + } + if ($this->maxLingerTime !== null) { + $xfer += $output->writeFieldBegin('maxLingerTime', TType::I32, 11); + $xfer += $output->writeI32($this->maxLingerTime); + $xfer += $output->writeFieldEnd(); + } + if ($this->result !== null) { + if (!is_object($this->result)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('result', TType::STRUCT, 50); + $xfer += $this->result->write($output); + $xfer += $output->writeFieldEnd(); + } + if ($this->version !== null) { + $xfer += $output->writeFieldBegin('version', TType::STRING, 60); + $xfer += $output->writeString($this->version); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class PullResponse { + static $_TSPEC; + + /** + * @var \didi\carrera\consumer\proxy\Context + */ + public $context = null; + /** + * @var \didi\carrera\consumer\proxy\Message[] + */ + public $messages = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'context', + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\Context', + ), + 2 => array( + 'var' => 'messages', + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\Message', + ), + ), + ); + } + if (is_array($vals)) { + if (isset($vals['context'])) { + $this->context = $vals['context']; + } + if (isset($vals['messages'])) { + $this->messages = $vals['messages']; + } + } + } + + public function getName() { + return 'PullResponse'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRUCT) { + $this->context = new \didi\carrera\consumer\proxy\Context(); + $xfer += $this->context->read($input); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::LST) { + $this->messages = array(); + $_size23 = 0; + $_etype26 = 0; + $xfer += $input->readListBegin($_etype26, $_size23); + for ($_i27 = 0; $_i27 < $_size23; ++$_i27) + { + $elem28 = null; + $elem28 = new \didi\carrera\consumer\proxy\Message(); + $xfer += $elem28->read($input); + $this->messages []= $elem28; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('PullResponse'); + if ($this->context !== null) { + if (!is_object($this->context)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('context', TType::STRUCT, 1); + $xfer += $this->context->write($output); + $xfer += $output->writeFieldEnd(); + } + if ($this->messages !== null) { + if (!is_array($this->messages)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('messages', TType::LST, 2); + { + $output->writeListBegin(TType::STRUCT, count($this->messages)); + { + foreach ($this->messages as $iter29) + { + $xfer += $iter29->write($output); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ConsumeStatsRequest { + static $_TSPEC; + + /** + * @var string + */ + public $group = null; + /** + * @var string + */ + public $topic = null; + /** + * @var string + */ + public $version = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'group', + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'topic', + 'type' => TType::STRING, + ), + 3 => array( + 'var' => 'version', + 'type' => TType::STRING, + ), + ); + } + if (is_array($vals)) { + if (isset($vals['group'])) { + $this->group = $vals['group']; + } + if (isset($vals['topic'])) { + $this->topic = $vals['topic']; + } + if (isset($vals['version'])) { + $this->version = $vals['version']; + } + } + } + + public function getName() { + return 'ConsumeStatsRequest'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->group); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->topic); + } else { + $xfer += $input->skip($ftype); + } + break; + case 3: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->version); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ConsumeStatsRequest'); + if ($this->group !== null) { + $xfer += $output->writeFieldBegin('group', TType::STRING, 1); + $xfer += $output->writeString($this->group); + $xfer += $output->writeFieldEnd(); + } + if ($this->topic !== null) { + $xfer += $output->writeFieldBegin('topic', TType::STRING, 2); + $xfer += $output->writeString($this->topic); + $xfer += $output->writeFieldEnd(); + } + if ($this->version !== null) { + $xfer += $output->writeFieldBegin('version', TType::STRING, 3); + $xfer += $output->writeString($this->version); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class FetchRequest { + static $_TSPEC; + + /** + * @var string + */ + public $consumerId = null; + /** + * @var string + */ + public $groupId = null; + /** + * @var string + */ + public $cluster = null; + /** + * @var array + */ + public $fetchOffset = null; + /** + * @var int + */ + public $maxBatchSize = null; + /** + * @var int + */ + public $maxLingerTime = null; + /** + * @var string + */ + public $version = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'consumerId', + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'groupId', + 'type' => TType::STRING, + ), + 3 => array( + 'var' => 'cluster', + 'type' => TType::STRING, + ), + 4 => array( + 'var' => 'fetchOffset', + 'type' => TType::MAP, + 'ktype' => TType::STRING, + 'vtype' => TType::MAP, + 'key' => array( + 'type' => TType::STRING, + ), + 'val' => array( + 'type' => TType::MAP, + 'ktype' => TType::STRING, + 'vtype' => TType::I64, + 'key' => array( + 'type' => TType::STRING, + ), + 'val' => array( + 'type' => TType::I64, + ), + ), + ), + 10 => array( + 'var' => 'maxBatchSize', + 'type' => TType::I32, + ), + 11 => array( + 'var' => 'maxLingerTime', + 'type' => TType::I32, + ), + 60 => array( + 'var' => 'version', + 'type' => TType::STRING, + ), + ); + } + if (is_array($vals)) { + if (isset($vals['consumerId'])) { + $this->consumerId = $vals['consumerId']; + } + if (isset($vals['groupId'])) { + $this->groupId = $vals['groupId']; + } + if (isset($vals['cluster'])) { + $this->cluster = $vals['cluster']; + } + if (isset($vals['fetchOffset'])) { + $this->fetchOffset = $vals['fetchOffset']; + } + if (isset($vals['maxBatchSize'])) { + $this->maxBatchSize = $vals['maxBatchSize']; + } + if (isset($vals['maxLingerTime'])) { + $this->maxLingerTime = $vals['maxLingerTime']; + } + if (isset($vals['version'])) { + $this->version = $vals['version']; + } + } + } + + public function getName() { + return 'FetchRequest'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->consumerId); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->groupId); + } else { + $xfer += $input->skip($ftype); + } + break; + case 3: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->cluster); + } else { + $xfer += $input->skip($ftype); + } + break; + case 4: + if ($ftype == TType::MAP) { + $this->fetchOffset = array(); + $_size30 = 0; + $_ktype31 = 0; + $_vtype32 = 0; + $xfer += $input->readMapBegin($_ktype31, $_vtype32, $_size30); + for ($_i34 = 0; $_i34 < $_size30; ++$_i34) + { + $key35 = ''; + $val36 = array(); + $xfer += $input->readString($key35); + $val36 = array(); + $_size37 = 0; + $_ktype38 = 0; + $_vtype39 = 0; + $xfer += $input->readMapBegin($_ktype38, $_vtype39, $_size37); + for ($_i41 = 0; $_i41 < $_size37; ++$_i41) + { + $key42 = ''; + $val43 = 0; + $xfer += $input->readString($key42); + $xfer += $input->readI64($val43); + $val36[$key42] = $val43; + } + $xfer += $input->readMapEnd(); + $this->fetchOffset[$key35] = $val36; + } + $xfer += $input->readMapEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + case 10: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->maxBatchSize); + } else { + $xfer += $input->skip($ftype); + } + break; + case 11: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->maxLingerTime); + } else { + $xfer += $input->skip($ftype); + } + break; + case 60: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->version); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('FetchRequest'); + if ($this->consumerId !== null) { + $xfer += $output->writeFieldBegin('consumerId', TType::STRING, 1); + $xfer += $output->writeString($this->consumerId); + $xfer += $output->writeFieldEnd(); + } + if ($this->groupId !== null) { + $xfer += $output->writeFieldBegin('groupId', TType::STRING, 2); + $xfer += $output->writeString($this->groupId); + $xfer += $output->writeFieldEnd(); + } + if ($this->cluster !== null) { + $xfer += $output->writeFieldBegin('cluster', TType::STRING, 3); + $xfer += $output->writeString($this->cluster); + $xfer += $output->writeFieldEnd(); + } + if ($this->fetchOffset !== null) { + if (!is_array($this->fetchOffset)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('fetchOffset', TType::MAP, 4); + { + $output->writeMapBegin(TType::STRING, TType::MAP, count($this->fetchOffset)); + { + foreach ($this->fetchOffset as $kiter44 => $viter45) + { + $xfer += $output->writeString($kiter44); + { + $output->writeMapBegin(TType::STRING, TType::I64, count($viter45)); + { + foreach ($viter45 as $kiter46 => $viter47) + { + $xfer += $output->writeString($kiter46); + $xfer += $output->writeI64($viter47); + } + } + $output->writeMapEnd(); + } + } + } + $output->writeMapEnd(); + } + $xfer += $output->writeFieldEnd(); + } + if ($this->maxBatchSize !== null) { + $xfer += $output->writeFieldBegin('maxBatchSize', TType::I32, 10); + $xfer += $output->writeI32($this->maxBatchSize); + $xfer += $output->writeFieldEnd(); + } + if ($this->maxLingerTime !== null) { + $xfer += $output->writeFieldBegin('maxLingerTime', TType::I32, 11); + $xfer += $output->writeI32($this->maxLingerTime); + $xfer += $output->writeFieldEnd(); + } + if ($this->version !== null) { + $xfer += $output->writeFieldBegin('version', TType::STRING, 60); + $xfer += $output->writeString($this->version); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class QidResponse { + static $_TSPEC; + + /** + * @var string + */ + public $topic = null; + /** + * @var string + */ + public $qid = null; + /** + * @var int + */ + public $nextRequestOffset = null; + /** + * @var \didi\carrera\consumer\proxy\Message[] + */ + public $messages = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'topic', + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'qid', + 'type' => TType::STRING, + ), + 3 => array( + 'var' => 'nextRequestOffset', + 'type' => TType::I64, + ), + 10 => array( + 'var' => 'messages', + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\Message', + ), + ), + ); + } + if (is_array($vals)) { + if (isset($vals['topic'])) { + $this->topic = $vals['topic']; + } + if (isset($vals['qid'])) { + $this->qid = $vals['qid']; + } + if (isset($vals['nextRequestOffset'])) { + $this->nextRequestOffset = $vals['nextRequestOffset']; + } + if (isset($vals['messages'])) { + $this->messages = $vals['messages']; + } + } + } + + public function getName() { + return 'QidResponse'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->topic); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->qid); + } else { + $xfer += $input->skip($ftype); + } + break; + case 3: + if ($ftype == TType::I64) { + $xfer += $input->readI64($this->nextRequestOffset); + } else { + $xfer += $input->skip($ftype); + } + break; + case 10: + if ($ftype == TType::LST) { + $this->messages = array(); + $_size48 = 0; + $_etype51 = 0; + $xfer += $input->readListBegin($_etype51, $_size48); + for ($_i52 = 0; $_i52 < $_size48; ++$_i52) + { + $elem53 = null; + $elem53 = new \didi\carrera\consumer\proxy\Message(); + $xfer += $elem53->read($input); + $this->messages []= $elem53; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('QidResponse'); + if ($this->topic !== null) { + $xfer += $output->writeFieldBegin('topic', TType::STRING, 1); + $xfer += $output->writeString($this->topic); + $xfer += $output->writeFieldEnd(); + } + if ($this->qid !== null) { + $xfer += $output->writeFieldBegin('qid', TType::STRING, 2); + $xfer += $output->writeString($this->qid); + $xfer += $output->writeFieldEnd(); + } + if ($this->nextRequestOffset !== null) { + $xfer += $output->writeFieldBegin('nextRequestOffset', TType::I64, 3); + $xfer += $output->writeI64($this->nextRequestOffset); + $xfer += $output->writeFieldEnd(); + } + if ($this->messages !== null) { + if (!is_array($this->messages)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('messages', TType::LST, 10); + { + $output->writeListBegin(TType::STRUCT, count($this->messages)); + { + foreach ($this->messages as $iter54) + { + $xfer += $iter54->write($output); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class FetchResponse { + static $_TSPEC; + + /** + * @var int + */ + public $code = null; + /** + * @var \didi\carrera\consumer\proxy\QidResponse[] + */ + public $results = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'code', + 'type' => TType::I32, + ), + 10 => array( + 'var' => 'results', + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\didi\carrera\consumer\proxy\QidResponse', + ), + ), + ); + } + if (is_array($vals)) { + if (isset($vals['code'])) { + $this->code = $vals['code']; + } + if (isset($vals['results'])) { + $this->results = $vals['results']; + } + } + } + + public function getName() { + return 'FetchResponse'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->code); + } else { + $xfer += $input->skip($ftype); + } + break; + case 10: + if ($ftype == TType::LST) { + $this->results = array(); + $_size55 = 0; + $_etype58 = 0; + $xfer += $input->readListBegin($_etype58, $_size55); + for ($_i59 = 0; $_i59 < $_size55; ++$_i59) + { + $elem60 = null; + $elem60 = new \didi\carrera\consumer\proxy\QidResponse(); + $xfer += $elem60->read($input); + $this->results []= $elem60; + } + $xfer += $input->readListEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('FetchResponse'); + if ($this->code !== null) { + $xfer += $output->writeFieldBegin('code', TType::I32, 1); + $xfer += $output->writeI32($this->code); + $xfer += $output->writeFieldEnd(); + } + if ($this->results !== null) { + if (!is_array($this->results)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('results', TType::LST, 10); + { + $output->writeListBegin(TType::STRUCT, count($this->results)); + { + foreach ($this->results as $iter61) + { + $xfer += $iter61->write($output); + } + } + $output->writeListEnd(); + } + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class AckResult { + static $_TSPEC; + + /** + * @var string + */ + public $consumerId = null; + /** + * @var string + */ + public $groupId = null; + /** + * @var string + */ + public $cluster = null; + /** + * @var array + */ + public $offsets = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'consumerId', + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'groupId', + 'type' => TType::STRING, + ), + 3 => array( + 'var' => 'cluster', + 'type' => TType::STRING, + ), + 4 => array( + 'var' => 'offsets', + 'type' => TType::MAP, + 'ktype' => TType::STRING, + 'vtype' => TType::MAP, + 'key' => array( + 'type' => TType::STRING, + ), + 'val' => array( + 'type' => TType::MAP, + 'ktype' => TType::STRING, + 'vtype' => TType::I64, + 'key' => array( + 'type' => TType::STRING, + ), + 'val' => array( + 'type' => TType::I64, + ), + ), + ), + ); + } + if (is_array($vals)) { + if (isset($vals['consumerId'])) { + $this->consumerId = $vals['consumerId']; + } + if (isset($vals['groupId'])) { + $this->groupId = $vals['groupId']; + } + if (isset($vals['cluster'])) { + $this->cluster = $vals['cluster']; + } + if (isset($vals['offsets'])) { + $this->offsets = $vals['offsets']; + } + } + } + + public function getName() { + return 'AckResult'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->consumerId); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->groupId); + } else { + $xfer += $input->skip($ftype); + } + break; + case 3: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->cluster); + } else { + $xfer += $input->skip($ftype); + } + break; + case 4: + if ($ftype == TType::MAP) { + $this->offsets = array(); + $_size62 = 0; + $_ktype63 = 0; + $_vtype64 = 0; + $xfer += $input->readMapBegin($_ktype63, $_vtype64, $_size62); + for ($_i66 = 0; $_i66 < $_size62; ++$_i66) + { + $key67 = ''; + $val68 = array(); + $xfer += $input->readString($key67); + $val68 = array(); + $_size69 = 0; + $_ktype70 = 0; + $_vtype71 = 0; + $xfer += $input->readMapBegin($_ktype70, $_vtype71, $_size69); + for ($_i73 = 0; $_i73 < $_size69; ++$_i73) + { + $key74 = ''; + $val75 = 0; + $xfer += $input->readString($key74); + $xfer += $input->readI64($val75); + $val68[$key74] = $val75; + } + $xfer += $input->readMapEnd(); + $this->offsets[$key67] = $val68; + } + $xfer += $input->readMapEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('AckResult'); + if ($this->consumerId !== null) { + $xfer += $output->writeFieldBegin('consumerId', TType::STRING, 1); + $xfer += $output->writeString($this->consumerId); + $xfer += $output->writeFieldEnd(); + } + if ($this->groupId !== null) { + $xfer += $output->writeFieldBegin('groupId', TType::STRING, 2); + $xfer += $output->writeString($this->groupId); + $xfer += $output->writeFieldEnd(); + } + if ($this->cluster !== null) { + $xfer += $output->writeFieldBegin('cluster', TType::STRING, 3); + $xfer += $output->writeString($this->cluster); + $xfer += $output->writeFieldEnd(); + } + if ($this->offsets !== null) { + if (!is_array($this->offsets)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('offsets', TType::MAP, 4); + { + $output->writeMapBegin(TType::STRING, TType::MAP, count($this->offsets)); + { + foreach ($this->offsets as $kiter76 => $viter77) + { + $xfer += $output->writeString($kiter76); + { + $output->writeMapBegin(TType::STRING, TType::I64, count($viter77)); + { + foreach ($viter77 as $kiter78 => $viter79) + { + $xfer += $output->writeString($kiter78); + $xfer += $output->writeI64($viter79); + } + } + $output->writeMapEnd(); + } + } + } + $output->writeMapEnd(); + } + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class ConsumeStats { + static $_TSPEC; + + /** + * @var string + */ + public $group = null; + /** + * @var string + */ + public $topic = null; + /** + * @var array + */ + public $consumeOffsets = null; + /** + * @var array + */ + public $produceOffsets = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'group', + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'topic', + 'type' => TType::STRING, + ), + 3 => array( + 'var' => 'consumeOffsets', + 'type' => TType::MAP, + 'ktype' => TType::STRING, + 'vtype' => TType::I64, + 'key' => array( + 'type' => TType::STRING, + ), + 'val' => array( + 'type' => TType::I64, + ), + ), + 4 => array( + 'var' => 'produceOffsets', + 'type' => TType::MAP, + 'ktype' => TType::STRING, + 'vtype' => TType::I64, + 'key' => array( + 'type' => TType::STRING, + ), + 'val' => array( + 'type' => TType::I64, + ), + ), + ); + } + if (is_array($vals)) { + if (isset($vals['group'])) { + $this->group = $vals['group']; + } + if (isset($vals['topic'])) { + $this->topic = $vals['topic']; + } + if (isset($vals['consumeOffsets'])) { + $this->consumeOffsets = $vals['consumeOffsets']; + } + if (isset($vals['produceOffsets'])) { + $this->produceOffsets = $vals['produceOffsets']; + } + } + } + + public function getName() { + return 'ConsumeStats'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->group); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->topic); + } else { + $xfer += $input->skip($ftype); + } + break; + case 3: + if ($ftype == TType::MAP) { + $this->consumeOffsets = array(); + $_size80 = 0; + $_ktype81 = 0; + $_vtype82 = 0; + $xfer += $input->readMapBegin($_ktype81, $_vtype82, $_size80); + for ($_i84 = 0; $_i84 < $_size80; ++$_i84) + { + $key85 = ''; + $val86 = 0; + $xfer += $input->readString($key85); + $xfer += $input->readI64($val86); + $this->consumeOffsets[$key85] = $val86; + } + $xfer += $input->readMapEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + case 4: + if ($ftype == TType::MAP) { + $this->produceOffsets = array(); + $_size87 = 0; + $_ktype88 = 0; + $_vtype89 = 0; + $xfer += $input->readMapBegin($_ktype88, $_vtype89, $_size87); + for ($_i91 = 0; $_i91 < $_size87; ++$_i91) + { + $key92 = ''; + $val93 = 0; + $xfer += $input->readString($key92); + $xfer += $input->readI64($val93); + $this->produceOffsets[$key92] = $val93; + } + $xfer += $input->readMapEnd(); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('ConsumeStats'); + if ($this->group !== null) { + $xfer += $output->writeFieldBegin('group', TType::STRING, 1); + $xfer += $output->writeString($this->group); + $xfer += $output->writeFieldEnd(); + } + if ($this->topic !== null) { + $xfer += $output->writeFieldBegin('topic', TType::STRING, 2); + $xfer += $output->writeString($this->topic); + $xfer += $output->writeFieldEnd(); + } + if ($this->consumeOffsets !== null) { + if (!is_array($this->consumeOffsets)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('consumeOffsets', TType::MAP, 3); + { + $output->writeMapBegin(TType::STRING, TType::I64, count($this->consumeOffsets)); + { + foreach ($this->consumeOffsets as $kiter94 => $viter95) + { + $xfer += $output->writeString($kiter94); + $xfer += $output->writeI64($viter95); + } + } + $output->writeMapEnd(); + } + $xfer += $output->writeFieldEnd(); + } + if ($this->produceOffsets !== null) { + if (!is_array($this->produceOffsets)) { + throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); + } + $xfer += $output->writeFieldBegin('produceOffsets', TType::MAP, 4); + { + $output->writeMapBegin(TType::STRING, TType::I64, count($this->produceOffsets)); + { + foreach ($this->produceOffsets as $kiter96 => $viter97) + { + $xfer += $output->writeString($kiter96); + $xfer += $output->writeI64($viter97); + } + } + $output->writeMapEnd(); + } + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + +class PullException extends TException { + static $_TSPEC; + + /** + * @var int + */ + public $code = null; + /** + * @var string + */ + public $message = null; + + public function __construct($vals=null) { + if (!isset(self::$_TSPEC)) { + self::$_TSPEC = array( + 1 => array( + 'var' => 'code', + 'type' => TType::I32, + ), + 2 => array( + 'var' => 'message', + 'type' => TType::STRING, + ), + ); + } + if (is_array($vals)) { + if (isset($vals['code'])) { + $this->code = $vals['code']; + } + if (isset($vals['message'])) { + $this->message = $vals['message']; + } + } + } + + public function getName() { + return 'PullException'; + } + + public function read($input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) + { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + switch ($fid) + { + case 1: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->code); + } else { + $xfer += $input->skip($ftype); + } + break; + case 2: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->message); + } else { + $xfer += $input->skip($ftype); + } + break; + default: + $xfer += $input->skip($ftype); + break; + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + return $xfer; + } + + public function write($output) { + $xfer = 0; + $xfer += $output->writeStructBegin('PullException'); + if ($this->code !== null) { + $xfer += $output->writeFieldBegin('code', TType::I32, 1); + $xfer += $output->writeI32($this->code); + $xfer += $output->writeFieldEnd(); + } + if ($this->message !== null) { + $xfer += $output->writeFieldBegin('message', TType::STRING, 2); + $xfer += $output->writeString($this->message); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + return $xfer; + } + +} + + diff --git a/carrera-sdk/consumer/php/libraries/carrera/thriftconf.php b/carrera-sdk/consumer/php/libraries/carrera/thriftconf.php new file mode 100644 index 0000000..9ad6d83 --- /dev/null +++ b/carrera-sdk/consumer/php/libraries/carrera/thriftconf.php @@ -0,0 +1,28 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + +