diff options
author | Jan Tattermusch <jtattermusch@google.com> | 2016-06-15 08:40:50 -0700 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@google.com> | 2016-06-15 08:40:50 -0700 |
commit | f8bd01f934f39ea21988ae3f9aa596e52b4481c6 (patch) | |
tree | 7fde7c7987c979d6afbd1ec7554785925f6b7b66 /src/php | |
parent | f2ce4307bfc639a1cde97b704c7df29246cf6ae3 (diff) | |
parent | 8fb6c924b54775be2d9fea52a39cc930460558de (diff) |
Merge remote-tracking branch 'upstream/master' into manual_upmerge_0_14_to_master
Diffstat (limited to 'src/php')
-rw-r--r-- | src/php/lib/Grpc/AbstractCall.php | 10 | ||||
-rwxr-xr-x | src/php/lib/Grpc/BaseStub.php | 13 | ||||
-rw-r--r-- | src/php/lib/Grpc/BidiStreamingCall.php | 1 | ||||
-rw-r--r-- | src/php/lib/Grpc/ClientStreamingCall.php | 4 | ||||
-rw-r--r-- | src/php/lib/Grpc/ServerStreamingCall.php | 1 | ||||
-rw-r--r-- | src/php/lib/Grpc/UnaryCall.php | 4 |
6 files changed, 29 insertions, 4 deletions
diff --git a/src/php/lib/Grpc/AbstractCall.php b/src/php/lib/Grpc/AbstractCall.php index 712af91eb2..c86d298805 100644 --- a/src/php/lib/Grpc/AbstractCall.php +++ b/src/php/lib/Grpc/AbstractCall.php @@ -39,6 +39,7 @@ abstract class AbstractCall protected $call; protected $deserialize; protected $metadata; + protected $trailing_metadata; /** * Create a new Call wrapper object. @@ -66,6 +67,7 @@ abstract class AbstractCall $this->call = new Call($channel, $method, $deadline); $this->deserialize = $deserialize; $this->metadata = null; + $this->trailing_metadata = null; if (isset($options['call_credentials_callback']) && is_callable($call_credentials_callback = $options['call_credentials_callback'])) { @@ -84,6 +86,14 @@ abstract class AbstractCall } /** + * @return The trailing metadata sent by the server. + */ + public function getTrailingMetadata() + { + return $this->trailing_metadata; + } + + /** * @return string The URI of the endpoint. */ public function getPeer() diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php index 2de1b337e5..70644fac87 100755 --- a/src/php/lib/Grpc/BaseStub.php +++ b/src/php/lib/Grpc/BaseStub.php @@ -52,8 +52,9 @@ class BaseStub * - 'update_metadata': (optional) a callback function which takes in a * metadata array, and returns an updated metadata array * - 'grpc.primary_user_agent': (optional) a user-agent string + * @param $channel Channel An already created Channel object */ - public function __construct($hostname, $opts) + public function __construct($hostname, $opts, $channel = null) { $this->hostname = $hostname; $this->update_metadata = null; @@ -77,7 +78,15 @@ class BaseStub 'required. Please see one of the '. 'ChannelCredentials::create methods'); } - $this->channel = new Channel($hostname, $opts); + if ($channel) { + if (!is_a($channel, 'Channel')) { + throw new \Exception("The channel argument is not a". + "Channel object"); + } + $this->channel = $channel; + } else { + $this->channel = new Channel($hostname, $opts); + } } /** diff --git a/src/php/lib/Grpc/BidiStreamingCall.php b/src/php/lib/Grpc/BidiStreamingCall.php index bf813c12e7..95e51c5088 100644 --- a/src/php/lib/Grpc/BidiStreamingCall.php +++ b/src/php/lib/Grpc/BidiStreamingCall.php @@ -112,6 +112,7 @@ class BidiStreamingCall extends AbstractCall OP_RECV_STATUS_ON_CLIENT => true, ]); + $this->trailing_metadata = $status_event->status->metadata; return $status_event->status; } } diff --git a/src/php/lib/Grpc/ClientStreamingCall.php b/src/php/lib/Grpc/ClientStreamingCall.php index 500cfe0d7a..315a406735 100644 --- a/src/php/lib/Grpc/ClientStreamingCall.php +++ b/src/php/lib/Grpc/ClientStreamingCall.php @@ -86,6 +86,8 @@ class ClientStreamingCall extends AbstractCall ]); $this->metadata = $event->metadata; - return [$this->deserializeResponse($event->message), $event->status]; + $status = $event->status; + $this->trailing_metadata = $status->metadata; + return [$this->deserializeResponse($event->message), $status]; } } diff --git a/src/php/lib/Grpc/ServerStreamingCall.php b/src/php/lib/Grpc/ServerStreamingCall.php index da48523717..53599fe4ae 100644 --- a/src/php/lib/Grpc/ServerStreamingCall.php +++ b/src/php/lib/Grpc/ServerStreamingCall.php @@ -91,6 +91,7 @@ class ServerStreamingCall extends AbstractCall OP_RECV_STATUS_ON_CLIENT => true, ]); + $this->trailing_metadata = $status_event->status->metadata; return $status_event->status; } } diff --git a/src/php/lib/Grpc/UnaryCall.php b/src/php/lib/Grpc/UnaryCall.php index b57903d6d0..b114b771b8 100644 --- a/src/php/lib/Grpc/UnaryCall.php +++ b/src/php/lib/Grpc/UnaryCall.php @@ -75,6 +75,8 @@ class UnaryCall extends AbstractCall OP_RECV_STATUS_ON_CLIENT => true, ]); - return [$this->deserializeResponse($event->message), $event->status]; + $status = $event->status; + $this->trailing_metadata = $status->metadata; + return [$this->deserializeResponse($event->message), $status]; } } |