aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/lib/Grpc/BaseStub.php
diff options
context:
space:
mode:
authorGravatar Stanley Cheung <stanleycheung@google.com>2015-06-15 11:45:00 -0700
committerGravatar Stanley Cheung <stanleycheung@google.com>2015-06-15 17:22:39 -0700
commitcc019af9cc2951bf7e0cdc17fb118e239dc785c3 (patch)
treee2fa22fb3dac1de958b5feddfaae413806a1c273 /src/php/lib/Grpc/BaseStub.php
parent0d6cf992e8f840ae257c039f15fc045e9605090f (diff)
add PHP timeout interop test
Diffstat (limited to 'src/php/lib/Grpc/BaseStub.php')
-rwxr-xr-xsrc/php/lib/Grpc/BaseStub.php31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php
index b84b6b86f8..48c00977eb 100755
--- a/src/php/lib/Grpc/BaseStub.php
+++ b/src/php/lib/Grpc/BaseStub.php
@@ -83,6 +83,21 @@ class BaseStub {
return "https://" . $this->hostname . $service_name;
}
+ /**
+ * extract $timeout from $metadata
+ * @param $metadata The metadata map
+ * @return list($metadata_copy, $timeout)
+ */
+ private function _extract_timeout_from_metadata($metadata) {
+ $timeout = false;
+ $metadata_copy = $metadata;
+ if (isset($metadata['timeout'])) {
+ $timeout = $metadata['timeout'];
+ unset($metadata_copy['timeout']);
+ }
+ return array($metadata_copy, $timeout);
+ }
+
/* This class is intended to be subclassed by generated code, so all functions
begin with "_" to avoid name collisions. */
@@ -99,8 +114,8 @@ class BaseStub {
$argument,
callable $deserialize,
$metadata = array()) {
- $call = new UnaryCall($this->channel, $method, $deserialize);
- $actual_metadata = $metadata;
+ list($actual_metadata, $timeout) = $this->_extract_timeout_from_metadata($metadata);
+ $call = new UnaryCall($this->channel, $method, $deserialize, $timeout);
$jwt_aud_uri = $this->_get_jwt_aud_uri($method);
if (is_callable($this->update_metadata)) {
$actual_metadata = call_user_func($this->update_metadata,
@@ -126,8 +141,8 @@ class BaseStub {
$arguments,
callable $deserialize,
$metadata = array()) {
- $call = new ClientStreamingCall($this->channel, $method, $deserialize);
- $actual_metadata = $metadata;
+ list($actual_metadata, $timeout) = $this->_extract_timeout_from_metadata($metadata);
+ $call = new ClientStreamingCall($this->channel, $method, $deserialize, $timeout);
$jwt_aud_uri = $this->_get_jwt_aud_uri($method);
if (is_callable($this->update_metadata)) {
$actual_metadata = call_user_func($this->update_metadata,
@@ -152,8 +167,8 @@ class BaseStub {
$argument,
callable $deserialize,
$metadata = array()) {
- $call = new ServerStreamingCall($this->channel, $method, $deserialize);
- $actual_metadata = $metadata;
+ list($actual_metadata, $timeout) = $this->_extract_timeout_from_metadata($metadata);
+ $call = new ServerStreamingCall($this->channel, $method, $deserialize, $timeout);
$jwt_aud_uri = $this->_get_jwt_aud_uri($method);
if (is_callable($this->update_metadata)) {
$actual_metadata = call_user_func($this->update_metadata,
@@ -175,8 +190,8 @@ class BaseStub {
public function _bidiRequest($method,
callable $deserialize,
$metadata = array()) {
- $call = new BidiStreamingCall($this->channel, $method, $deserialize);
- $actual_metadata = $metadata;
+ list($actual_metadata, $timeout) = $this->_extract_timeout_from_metadata($metadata);
+ $call = new BidiStreamingCall($this->channel, $method, $deserialize, $timeout);
$jwt_aud_uri = $this->_get_jwt_aud_uri($method);
if (is_callable($this->update_metadata)) {
$actual_metadata = call_user_func($this->update_metadata,