GRPC PHP  1.66.0
Public Member Functions | Static Public Member Functions | Protected Member Functions
Grpc\BaseStub Class Reference

Base class for generated client stubs. More...

Public Member Functions

 __construct ($hostname, $opts, $channel=null)
 
 getTarget ()
 
 getConnectivityState ($try_to_connect=false)
 
 waitForReady ($timeout)
 
 close ()
 Close the communication channel associated with this stub. More...
 

Static Public Member Functions

static getDefaultChannel ($hostname, array $opts)
 Creates and returns the default Channel. More...
 

Protected Member Functions

 _simpleRequest ( $method, $argument, $deserialize, array $metadata=[], array $options=[])
 Call a remote method that takes a single argument and has a single output. More...
 
 _clientStreamRequest ( $method, $deserialize, array $metadata=[], array $options=[])
 Call a remote method that takes a stream of arguments and has a single output. More...
 
 _serverStreamRequest ( $method, $argument, $deserialize, array $metadata=[], array $options=[])
 Call a remote method that takes a single argument and returns a stream of responses. More...
 
 _bidiRequest ( $method, $deserialize, array $metadata=[], array $options=[])
 Call a remote method with messages streaming in both directions. More...
 

Detailed Description

Base class for generated client stubs.

Stub methods are expected to call _simpleRequest or _streamRequest and return the result.

Constructor & Destructor Documentation

◆ __construct()

Grpc\BaseStub::__construct (   $hostname,
  $opts,
  $channel = null 
)
Parameters
string$hostname
array$opts
  • '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
Channel | InterceptorChannel$channelAn already created Channel or InterceptorChannel object (optional)

Member Function Documentation

◆ _bidiRequest()

Grpc\BaseStub::_bidiRequest (   $method,
  $deserialize,
array  $metadata = [],
array  $options = [] 
)
protected

Call a remote method with messages streaming in both directions.

Parameters
string$methodThe name of the method to call
callable$deserializeA function that deserializes the responses
array$metadataA metadata map to send to the server (optional)
array$optionsAn array of options (optional)
Returns
BidiStreamingCall The active call object

◆ _clientStreamRequest()

Grpc\BaseStub::_clientStreamRequest (   $method,
  $deserialize,
array  $metadata = [],
array  $options = [] 
)
protected

Call a remote method that takes a stream of arguments and has a single output.

Parameters
string$methodThe name of the method to call
callable$deserializeA function that deserializes the response
array$metadataA metadata map to send to the server (optional)
array$optionsAn array of options (optional)
Returns
ClientStreamingCall The active call object

◆ _serverStreamRequest()

Grpc\BaseStub::_serverStreamRequest (   $method,
  $argument,
  $deserialize,
array  $metadata = [],
array  $options = [] 
)
protected

Call a remote method that takes a single argument and returns a stream of responses.

Parameters
string$methodThe name of the method to call
mixed$argumentThe argument to the method
callable$deserializeA function that deserializes the responses
array$metadataA metadata map to send to the server (optional)
array$optionsAn array of options (optional)
Returns
ServerStreamingCall The active call object

◆ _simpleRequest()

Grpc\BaseStub::_simpleRequest (   $method,
  $argument,
  $deserialize,
array  $metadata = [],
array  $options = [] 
)
protected

Call a remote method that takes a single argument and has a single output.

Parameters
string$methodThe name of the method to call
mixed$argumentThe argument to the method
callable$deserializeA function that deserializes the response
array$metadataA metadata map to send to the server (optional)
array$optionsAn array of options (optional)
Returns
UnaryCall The active call object

◆ close()

Grpc\BaseStub::close ( )

Close the communication channel associated with this stub.

◆ getConnectivityState()

Grpc\BaseStub::getConnectivityState (   $try_to_connect = false)
Parameters
bool$try_to_connect(optional)
Returns
int The grpc connectivity state

◆ getDefaultChannel()

static Grpc\BaseStub::getDefaultChannel (   $hostname,
array  $opts 
)
static

Creates and returns the default Channel.

Parameters
array$optsChannel constructor options
Returns
Channel The channel

◆ getTarget()

Grpc\BaseStub::getTarget ( )
Returns
string The URI of the endpoint

◆ waitForReady()

Grpc\BaseStub::waitForReady (   $timeout)
Parameters
int$timeoutin microseconds
Returns
bool true if channel is ready
Exceptions
Exceptionif channel is in FATAL_ERROR state

The documentation for this class was generated from the following file: