Copied!

A gRPC based transport implementation.

CloneableInstantiable
Methods
public __construct(string $hostname, array $opts, ?Grpc\Channel $channel = NULL, array $interceptors = [], Psr\Log\LoggerInterface|false|?null $logger = NULL)
 
  • param string $hostname
  • param 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
  • param \Channel $channel An already created Channel object (optional)
  • param \Interceptor[]|\UnaryInterceptorInterface[] $interceptors EXPERIMENTAL Interceptors used to intercept RPC invocations before a call starts. Please note that implementations of {@see \Google\ApiCore\Transport\Grpc\UnaryInterceptorInterface} are considered deprecated and support will be removed in a future release. To prepare for this, please take the time to convert UnaryInterceptorInterface implementations over to a class which extends {@see \Grpc\Interceptor}.
  • param null|false|\LoggerInterface $logger A PSR-3 Compliant logger.
  • throws \Exception
public static build(string $apiEndpoint, array $config = [])
 

Builds a GrpcTransport.

  • param string $apiEndpoint The address of the API remote host, for example "example.googleapis.com. May also
    •    include the port, for example "example.googleapis.com:443"
      
  • param array $config { Config options used to construct the gRPC transport. @type array $stubOpts Options used to construct the gRPC stub (see {@link https://grpc.github.io/grpc/core/group__grpc__arg__keys.html}). @type Channel $channel Grpc channel to be used. @type Interceptor[]|UnaryInterceptorInterface[] $interceptors EXPERIMENTAL Interceptors used to intercept RPC invocations before a call starts. Please note that implementations of {@see \Google\ApiCore\Transport\Grpc\UnaryInterceptorInterface} are considered deprecated and support will be removed in a future release. To prepare for this, please take the time to convert UnaryInterceptorInterface implementations over to a class which extends {@see \Grpc\Interceptor}. @type callable $clientCertSource A callable which returns the client cert as a string. }
  • return \GrpcTransport
  • throws \ValidationException
public Grpc\BaseStub::close()
 

Close the communication channel associated with this stub.

public Grpc\BaseStub::getConnectivityState( $try_to_connect = false)
 
  • param bool $try_to_connect (optional)
  • return int The grpc connectivity state
public static Grpc\BaseStub::getDefaultChannel( $hostname, array $opts)
 

Creates and returns the default Channel

  • param array $opts Channel constructor options
  • return \Channel The channel
public Grpc\BaseStub::getTarget()
 
  • return string The URI of the endpoint
public startBidiStreamingCall(Google\ApiCore\Call $call, array $options)
 
    public startClientStreamingCall(Google\ApiCore\Call $call, array $options)
     
      public startServerStreamingCall(Google\ApiCore\Call $call, array $options)
       
        public startUnaryCall(Google\ApiCore\Call $call, array $options)
         
          public static validate(array $arr, array $requiredKeys)
           
          • param array $arr Associative array
          • param array $requiredKeys List of keys to check for in $arr
          • return array Returns $arr for fluent use
          public static validateNotNull(array $arr, array $requiredKeys)
           
          • param array $arr Associative array
          • param array $requiredKeys List of keys to check for in $arr
          • return array Returns $arr for fluent use
          public Grpc\BaseStub::waitForReady( $timeout)
           
          • param int $timeout in microseconds
          • return bool true if channel is ready
          • throws \Exception if channel is in FATAL_ERROR state
          Methods
          protected Grpc\BaseStub::_bidiRequest( $method, $deserialize, array $metadata = [], array $options = [])
           

          Call a remote method with messages streaming in both directions.

          • param string $method The name of the method to call
          • param callable $deserialize A function that deserializes the responses
          • param array $metadata A metadata map to send to the server (optional)
          • param array $options An array of options (optional)
          • return \BidiStreamingCall The active call object
          protected Grpc\BaseStub::_clientStreamRequest( $method, $deserialize, array $metadata = [], array $options = [])
           

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

          • param string $method The name of the method to call
          • param callable $deserialize A function that deserializes the response
          • param array $metadata A metadata map to send to the server (optional)
          • param array $options An array of options (optional)
          • return \ClientStreamingCall The active call object
          protected Grpc\BaseStub::_serverStreamRequest( $method, $argument, $deserialize, array $metadata = [], array $options = [])
           

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

          • param string $method The name of the method to call
          • param mixed $argument The argument to the method
          • param callable $deserialize A function that deserializes the responses
          • param array $metadata A metadata map to send to the server (optional)
          • param array $options An array of options (optional)
          • return \ServerStreamingCall The active call object
          protected Grpc\BaseStub::_simpleRequest( $method, $argument, $deserialize, array $metadata = [], array $options = [])
           

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

          • param string $method The name of the method to call
          • param mixed $argument The argument to the method
          • param callable $deserialize A function that deserializes the response
          • param array $metadata A metadata map to send to the server (optional)
          • param array $options An array of options (optional)
          • return \UnaryCall The active call object
          Properties
          private static $defaultPort = 443
          private ?Psr\Log\LoggerInterface $logger
          Methods
          private getCallOptions(array $options)
          private static getGrpcDependencyStatus()
           
          • return bool
          private getJwtToken(array $headers) : ?array
           
          • param mixed[] $headers
          • return null|array<string, string|false>
          private static loadClientCertSource(callable $clientCertSource)
          private logRequest(Google\Auth\Logging\RpcLogEvent $event) : void
           
          • param \RpcLogEvent $event
          private logResponse(Google\Auth\Logging\RpcLogEvent $event) : void
           
          • param \RpcLogEvent $event
          private static normalizeServiceAddress(string $apiEndpoint)
           
          • param string $apiEndpoint
          • return array
          • throws \ValidationException
          private truncatePayload(?string $payload) : ?string
           
          • param null|string $payload
          • return string
          private static validateFileExists(string $filePath)
           
          • param string $filePath
          • throws \ValidationException
          private static validateGrpcSupport()
           
          • throws \ValidationException
          private static validateImpl( $arr, $requiredKeys, $allowNull)
          private verifyUniverseDomain(array $options)
          Properties
          private static $defaultPort = 443
          Methods
          public static build(string $apiEndpoint, array $config = [])
           

          Builds a GrpcTransport.

          • param string $apiEndpoint The address of the API remote host, for example "example.googleapis.com. May also
            •    include the port, for example "example.googleapis.com:443"
              
          • param array $config { Config options used to construct the gRPC transport. @type array $stubOpts Options used to construct the gRPC stub (see {@link https://grpc.github.io/grpc/core/group__grpc__arg__keys.html}). @type Channel $channel Grpc channel to be used. @type Interceptor[]|UnaryInterceptorInterface[] $interceptors EXPERIMENTAL Interceptors used to intercept RPC invocations before a call starts. Please note that implementations of {@see \Google\ApiCore\Transport\Grpc\UnaryInterceptorInterface} are considered deprecated and support will be removed in a future release. To prepare for this, please take the time to convert UnaryInterceptorInterface implementations over to a class which extends {@see \Grpc\Interceptor}. @type callable $clientCertSource A callable which returns the client cert as a string. }
          • return \GrpcTransport
          • throws \ValidationException
          public static Grpc\BaseStub::getDefaultChannel( $hostname, array $opts)
           

          Creates and returns the default Channel

          • param array $opts Channel constructor options
          • return \Channel The channel
          private static getGrpcDependencyStatus()
           
          • return bool
          private static loadClientCertSource(callable $clientCertSource)
          private static normalizeServiceAddress(string $apiEndpoint)
           
          • param string $apiEndpoint
          • return array
          • throws \ValidationException
          public static validate(array $arr, array $requiredKeys)
           
          • param array $arr Associative array
          • param array $requiredKeys List of keys to check for in $arr
          • return array Returns $arr for fluent use
          private static validateFileExists(string $filePath)
           
          • param string $filePath
          • throws \ValidationException
          private static validateGrpcSupport()
           
          • throws \ValidationException
          private static validateImpl( $arr, $requiredKeys, $allowNull)
          public static validateNotNull(array $arr, array $requiredKeys)
           
          • param array $arr Associative array
          • param array $requiredKeys List of keys to check for in $arr
          • return array Returns $arr for fluent use
          © 2026 Bruce Wells
          Search Namespaces \ Classes
          Configuration