diff options
author | 2015-06-15 11:45:00 -0700 | |
---|---|---|
committer | 2015-06-15 17:22:39 -0700 | |
commit | cc019af9cc2951bf7e0cdc17fb118e239dc785c3 (patch) | |
tree | e2fa22fb3dac1de958b5feddfaae413806a1c273 /src/php/lib/Grpc/AbstractCall.php | |
parent | 0d6cf992e8f840ae257c039f15fc045e9605090f (diff) |
add PHP timeout interop test
Diffstat (limited to 'src/php/lib/Grpc/AbstractCall.php')
-rw-r--r-- | src/php/lib/Grpc/AbstractCall.php | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/php/lib/Grpc/AbstractCall.php b/src/php/lib/Grpc/AbstractCall.php index 1add972589..5b28417a0d 100644 --- a/src/php/lib/Grpc/AbstractCall.php +++ b/src/php/lib/Grpc/AbstractCall.php @@ -43,9 +43,19 @@ abstract class AbstractCall { * Create a new Call wrapper object. * @param Channel $channel The channel to communicate on * @param string $method The method to call on the remote server + * @param callback $deserialize A callback function to deserialize + * the response + * @param (optional) long $timeout Timeout in microseconds */ - public function __construct(Channel $channel, $method, $deserialize) { - $this->call = new Call($channel, $method, Timeval::infFuture()); + public function __construct(Channel $channel, $method, $deserialize, $timeout = false) { + if ($timeout) { + $now = Timeval::now(); + $delta = new Timeval($timeout); + $deadline = $now->add($delta); + } else { + $deadline = Timeval::infFuture(); + } + $this->call = new Call($channel, $method, $deadline); $this->deserialize = $deserialize; $this->metadata = null; } |