diff options
author | Stanley Cheung <stanleycheung@google.com> | 2016-05-18 15:06:39 -0700 |
---|---|---|
committer | Stanley Cheung <stanleycheung@google.com> | 2016-06-13 09:38:14 -0700 |
commit | e05d31962dec34466417e17370dc3a169b6e5eb6 (patch) | |
tree | b9442f2580bc95fcff78074c7ee141a1d967e25f /src/php/lib/Grpc/BaseStub.php | |
parent | 55ca239bc2116857b347d8b1234e0cabf35640de (diff) |
php: add channel argument to BaseStub constructor
Diffstat (limited to 'src/php/lib/Grpc/BaseStub.php')
-rwxr-xr-x | src/php/lib/Grpc/BaseStub.php | 13 |
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); + } } /** |