aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/lib/Grpc/BaseStub.php
diff options
context:
space:
mode:
authorGravatar Sree Kuchibhotla <sreek@google.com>2016-06-13 16:44:08 -0700
committerGravatar Sree Kuchibhotla <sreek@google.com>2016-06-13 16:44:08 -0700
commitc0f4fe2dd4251f83d8ea97efa5561b9ae64d7a44 (patch)
treeb85f8f40ead4c72c7820a8dce98ce4f81717ca00 /src/php/lib/Grpc/BaseStub.php
parent41622a8e389e8eda38d6d3bfbf34cbf35f437156 (diff)
parenta47acad040242c03d5e812a40fd11225f327d45e (diff)
Merge branch 'master' into epoll_changes
Diffstat (limited to 'src/php/lib/Grpc/BaseStub.php')
-rwxr-xr-xsrc/php/lib/Grpc/BaseStub.php13
1 files changed, 11 insertions, 2 deletions
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);
+ }
}
/**