DocumentService.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <?php
  2. namespace OpenSearch\Generated\Document;
  3. /**
  4. * Autogenerated by Thrift Compiler (0.10.0)
  5. *
  6. * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  7. * @generated
  8. */
  9. use Thrift\Base\TBase;
  10. use Thrift\Type\TType;
  11. use Thrift\Type\TMessageType;
  12. use Thrift\Exception\TException;
  13. use Thrift\Exception\TProtocolException;
  14. use Thrift\Protocol\TProtocol;
  15. use Thrift\Protocol\TBinaryProtocolAccelerated;
  16. use Thrift\Exception\TApplicationException;
  17. interface DocumentServiceIf {
  18. /**
  19. * @param string $docsJson
  20. * @param string $appName
  21. * @param string $tableName
  22. * @return \OpenSearch\Generated\Common\OpenSearchResult
  23. * @throws \OpenSearch\Generated\Common\OpenSearchException
  24. * @throws \OpenSearch\Generated\Common\OpenSearchClientException
  25. */
  26. public function push($docsJson, $appName, $tableName);
  27. }
  28. class DocumentServiceClient implements \OpenSearch\Generated\Document\DocumentServiceIf {
  29. protected $input_ = null;
  30. protected $output_ = null;
  31. protected $seqid_ = 0;
  32. public function __construct($input, $output=null) {
  33. $this->input_ = $input;
  34. $this->output_ = $output ? $output : $input;
  35. }
  36. public function push($docsJson, $appName, $tableName)
  37. {
  38. $this->send_push($docsJson, $appName, $tableName);
  39. return $this->recv_push();
  40. }
  41. public function send_push($docsJson, $appName, $tableName)
  42. {
  43. $args = new \OpenSearch\Generated\Document\DocumentService_push_args();
  44. $args->docsJson = $docsJson;
  45. $args->appName = $appName;
  46. $args->tableName = $tableName;
  47. $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');
  48. if ($bin_accel)
  49. {
  50. thrift_protocol_write_binary($this->output_, 'push', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite());
  51. }
  52. else
  53. {
  54. $this->output_->writeMessageBegin('push', TMessageType::CALL, $this->seqid_);
  55. $args->write($this->output_);
  56. $this->output_->writeMessageEnd();
  57. $this->output_->getTransport()->flush();
  58. }
  59. }
  60. public function recv_push()
  61. {
  62. $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary');
  63. if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\OpenSearch\Generated\Document\DocumentService_push_result', $this->input_->isStrictRead());
  64. else
  65. {
  66. $rseqid = 0;
  67. $fname = null;
  68. $mtype = 0;
  69. $this->input_->readMessageBegin($fname, $mtype, $rseqid);
  70. if ($mtype == TMessageType::EXCEPTION) {
  71. $x = new TApplicationException();
  72. $x->read($this->input_);
  73. $this->input_->readMessageEnd();
  74. throw $x;
  75. }
  76. $result = new \OpenSearch\Generated\Document\DocumentService_push_result();
  77. $result->read($this->input_);
  78. $this->input_->readMessageEnd();
  79. }
  80. if ($result->success !== null) {
  81. return $result->success;
  82. }
  83. if ($result->error !== null) {
  84. throw $result->error;
  85. }
  86. if ($result->e !== null) {
  87. throw $result->e;
  88. }
  89. throw new \Exception("push failed: unknown result");
  90. }
  91. }
  92. // HELPER FUNCTIONS AND STRUCTURES
  93. class DocumentService_push_args {
  94. static $_TSPEC;
  95. /**
  96. * @var string
  97. */
  98. public $docsJson = null;
  99. /**
  100. * @var string
  101. */
  102. public $appName = null;
  103. /**
  104. * @var string
  105. */
  106. public $tableName = null;
  107. public function __construct($vals=null) {
  108. if (!isset(self::$_TSPEC)) {
  109. self::$_TSPEC = array(
  110. 1 => array(
  111. 'var' => 'docsJson',
  112. 'type' => TType::STRING,
  113. ),
  114. 2 => array(
  115. 'var' => 'appName',
  116. 'type' => TType::STRING,
  117. ),
  118. 3 => array(
  119. 'var' => 'tableName',
  120. 'type' => TType::STRING,
  121. ),
  122. );
  123. }
  124. if (is_array($vals)) {
  125. if (isset($vals['docsJson'])) {
  126. $this->docsJson = $vals['docsJson'];
  127. }
  128. if (isset($vals['appName'])) {
  129. $this->appName = $vals['appName'];
  130. }
  131. if (isset($vals['tableName'])) {
  132. $this->tableName = $vals['tableName'];
  133. }
  134. }
  135. }
  136. public function getName() {
  137. return 'DocumentService_push_args';
  138. }
  139. public function read($input)
  140. {
  141. $xfer = 0;
  142. $fname = null;
  143. $ftype = 0;
  144. $fid = 0;
  145. $xfer += $input->readStructBegin($fname);
  146. while (true)
  147. {
  148. $xfer += $input->readFieldBegin($fname, $ftype, $fid);
  149. if ($ftype == TType::STOP) {
  150. break;
  151. }
  152. switch ($fid)
  153. {
  154. case 1:
  155. if ($ftype == TType::STRING) {
  156. $xfer += $input->readString($this->docsJson);
  157. } else {
  158. $xfer += $input->skip($ftype);
  159. }
  160. break;
  161. case 2:
  162. if ($ftype == TType::STRING) {
  163. $xfer += $input->readString($this->appName);
  164. } else {
  165. $xfer += $input->skip($ftype);
  166. }
  167. break;
  168. case 3:
  169. if ($ftype == TType::STRING) {
  170. $xfer += $input->readString($this->tableName);
  171. } else {
  172. $xfer += $input->skip($ftype);
  173. }
  174. break;
  175. default:
  176. $xfer += $input->skip($ftype);
  177. break;
  178. }
  179. $xfer += $input->readFieldEnd();
  180. }
  181. $xfer += $input->readStructEnd();
  182. return $xfer;
  183. }
  184. public function write($output) {
  185. $xfer = 0;
  186. $xfer += $output->writeStructBegin('DocumentService_push_args');
  187. if ($this->docsJson !== null) {
  188. $xfer += $output->writeFieldBegin('docsJson', TType::STRING, 1);
  189. $xfer += $output->writeString($this->docsJson);
  190. $xfer += $output->writeFieldEnd();
  191. }
  192. if ($this->appName !== null) {
  193. $xfer += $output->writeFieldBegin('appName', TType::STRING, 2);
  194. $xfer += $output->writeString($this->appName);
  195. $xfer += $output->writeFieldEnd();
  196. }
  197. if ($this->tableName !== null) {
  198. $xfer += $output->writeFieldBegin('tableName', TType::STRING, 3);
  199. $xfer += $output->writeString($this->tableName);
  200. $xfer += $output->writeFieldEnd();
  201. }
  202. $xfer += $output->writeFieldStop();
  203. $xfer += $output->writeStructEnd();
  204. return $xfer;
  205. }
  206. }
  207. class DocumentService_push_result {
  208. static $_TSPEC;
  209. /**
  210. * @var \OpenSearch\Generated\Common\OpenSearchResult
  211. */
  212. public $success = null;
  213. /**
  214. * @var \OpenSearch\Generated\Common\OpenSearchException
  215. */
  216. public $error = null;
  217. /**
  218. * @var \OpenSearch\Generated\Common\OpenSearchClientException
  219. */
  220. public $e = null;
  221. public function __construct($vals=null) {
  222. if (!isset(self::$_TSPEC)) {
  223. self::$_TSPEC = array(
  224. 0 => array(
  225. 'var' => 'success',
  226. 'type' => TType::STRUCT,
  227. 'class' => '\OpenSearch\Generated\Common\OpenSearchResult',
  228. ),
  229. 1 => array(
  230. 'var' => 'error',
  231. 'type' => TType::STRUCT,
  232. 'class' => '\OpenSearch\Generated\Common\OpenSearchException',
  233. ),
  234. 2 => array(
  235. 'var' => 'e',
  236. 'type' => TType::STRUCT,
  237. 'class' => '\OpenSearch\Generated\Common\OpenSearchClientException',
  238. ),
  239. );
  240. }
  241. if (is_array($vals)) {
  242. if (isset($vals['success'])) {
  243. $this->success = $vals['success'];
  244. }
  245. if (isset($vals['error'])) {
  246. $this->error = $vals['error'];
  247. }
  248. if (isset($vals['e'])) {
  249. $this->e = $vals['e'];
  250. }
  251. }
  252. }
  253. public function getName() {
  254. return 'DocumentService_push_result';
  255. }
  256. public function read($input)
  257. {
  258. $xfer = 0;
  259. $fname = null;
  260. $ftype = 0;
  261. $fid = 0;
  262. $xfer += $input->readStructBegin($fname);
  263. while (true)
  264. {
  265. $xfer += $input->readFieldBegin($fname, $ftype, $fid);
  266. if ($ftype == TType::STOP) {
  267. break;
  268. }
  269. switch ($fid)
  270. {
  271. case 0:
  272. if ($ftype == TType::STRUCT) {
  273. $this->success = new \OpenSearch\Generated\Common\OpenSearchResult();
  274. $xfer += $this->success->read($input);
  275. } else {
  276. $xfer += $input->skip($ftype);
  277. }
  278. break;
  279. case 1:
  280. if ($ftype == TType::STRUCT) {
  281. $this->error = new \OpenSearch\Generated\Common\OpenSearchException();
  282. $xfer += $this->error->read($input);
  283. } else {
  284. $xfer += $input->skip($ftype);
  285. }
  286. break;
  287. case 2:
  288. if ($ftype == TType::STRUCT) {
  289. $this->e = new \OpenSearch\Generated\Common\OpenSearchClientException();
  290. $xfer += $this->e->read($input);
  291. } else {
  292. $xfer += $input->skip($ftype);
  293. }
  294. break;
  295. default:
  296. $xfer += $input->skip($ftype);
  297. break;
  298. }
  299. $xfer += $input->readFieldEnd();
  300. }
  301. $xfer += $input->readStructEnd();
  302. return $xfer;
  303. }
  304. public function write($output) {
  305. $xfer = 0;
  306. $xfer += $output->writeStructBegin('DocumentService_push_result');
  307. if ($this->success !== null) {
  308. if (!is_object($this->success)) {
  309. throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
  310. }
  311. $xfer += $output->writeFieldBegin('success', TType::STRUCT, 0);
  312. $xfer += $this->success->write($output);
  313. $xfer += $output->writeFieldEnd();
  314. }
  315. if ($this->error !== null) {
  316. $xfer += $output->writeFieldBegin('error', TType::STRUCT, 1);
  317. $xfer += $this->error->write($output);
  318. $xfer += $output->writeFieldEnd();
  319. }
  320. if ($this->e !== null) {
  321. $xfer += $output->writeFieldBegin('e', TType::STRUCT, 2);
  322. $xfer += $this->e->write($output);
  323. $xfer += $output->writeFieldEnd();
  324. }
  325. $xfer += $output->writeFieldStop();
  326. $xfer += $output->writeStructEnd();
  327. return $xfer;
  328. }
  329. }
  330. class DocumentServiceProcessor {
  331. protected $handler_ = null;
  332. public function __construct($handler) {
  333. $this->handler_ = $handler;
  334. }
  335. public function process($input, $output) {
  336. $rseqid = 0;
  337. $fname = null;
  338. $mtype = 0;
  339. $input->readMessageBegin($fname, $mtype, $rseqid);
  340. $methodname = 'process_'.$fname;
  341. if (!method_exists($this, $methodname)) {
  342. $input->skip(TType::STRUCT);
  343. $input->readMessageEnd();
  344. $x = new TApplicationException('Function '.$fname.' not implemented.', TApplicationException::UNKNOWN_METHOD);
  345. $output->writeMessageBegin($fname, TMessageType::EXCEPTION, $rseqid);
  346. $x->write($output);
  347. $output->writeMessageEnd();
  348. $output->getTransport()->flush();
  349. return;
  350. }
  351. $this->$methodname($rseqid, $input, $output);
  352. return true;
  353. }
  354. protected function process_push($seqid, $input, $output) {
  355. $args = new \OpenSearch\Generated\Document\DocumentService_push_args();
  356. $args->read($input);
  357. $input->readMessageEnd();
  358. $result = new \OpenSearch\Generated\Document\DocumentService_push_result();
  359. try {
  360. $result->success = $this->handler_->push($args->docsJson, $args->appName, $args->tableName);
  361. } catch (\OpenSearch\Generated\Common\OpenSearchException $error) {
  362. $result->error = $error;
  363. } catch (\OpenSearch\Generated\Common\OpenSearchClientException $e) {
  364. $result->e = $e;
  365. }
  366. $bin_accel = ($output instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');
  367. if ($bin_accel)
  368. {
  369. thrift_protocol_write_binary($output, 'push', TMessageType::REPLY, $result, $seqid, $output->isStrictWrite());
  370. }
  371. else
  372. {
  373. $output->writeMessageBegin('push', TMessageType::REPLY, $seqid);
  374. $result->write($output);
  375. $output->writeMessageEnd();
  376. $output->getTransport()->flush();
  377. }
  378. }
  379. }