generated
3 years ago
ChannelRef.php
3 years ago
Config.php
3 years ago
CreatedByDeserializeCheck.php
3 years ago
GCPBidiStreamingCall.php
3 years ago
GCPCallInvoker.php
3 years ago
GCPClientStreamCall.php
3 years ago
GCPServerStreamCall.php
3 years ago
GCPUnaryCall.php
3 years ago
GcpBaseCall.php
3 years ago
GcpExtensionChannel.php
3 years ago
grpc_gcp.proto
3 years ago
GCPUnaryCall.php
71 lines
| 1 | <?php |
| 2 | /* |
| 3 | * |
| 4 | * Copyright 2018 gRPC authors. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | * |
| 18 | */ |
| 19 | namespace Grpc\Gcp; |
| 20 | |
| 21 | /** |
| 22 | * Represents an active call that sends a single message and then gets a |
| 23 | * single response. |
| 24 | */ |
| 25 | class GCPUnaryCall extends GcpBaseCall |
| 26 | { |
| 27 | protected function createRealCall($channel) |
| 28 | { |
| 29 | $this->real_call = new \Grpc\UnaryCall($channel, $this->method, $this->deserialize, $this->options); |
| 30 | $this->has_real_call = true; |
| 31 | return $this->real_call; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Pick a channel and start the call. |
| 36 | * |
| 37 | * @param mixed $data The data to send |
| 38 | * @param array $metadata Metadata to send with the call, if applicable |
| 39 | * (optional) |
| 40 | * @param array $options An array of options, possible keys: |
| 41 | * 'flags' => a number (optional) |
| 42 | */ |
| 43 | public function start($argument, $metadata, $options) |
| 44 | { |
| 45 | $channel_ref = $this->_rpcPreProcess($argument); |
| 46 | $real_channel = $channel_ref->getRealChannel($this->gcp_channel->credentials); |
| 47 | $this->createRealCall($real_channel); |
| 48 | $this->real_call->start($argument, $metadata, $options); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Wait for the server to respond with data and a status. |
| 53 | * |
| 54 | * @return array [response data, status] |
| 55 | */ |
| 56 | public function wait() |
| 57 | { |
| 58 | list($response, $status) = $this->real_call->wait(); |
| 59 | $this->_rpcPostProcess($status, $response); |
| 60 | return [$response, $status]; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * @return mixed The metadata sent by the server |
| 65 | */ |
| 66 | public function getMetadata() |
| 67 | { |
| 68 | return $this->real_call->getMetadata(); |
| 69 | } |
| 70 | } |
| 71 |