src/Transport/GrpcTransport.php
public static function build($serviceAddress, array $config = [])
    {
        self::validateGrpcSupport();
        $config += [
            'stubOpts'     => [],
            'channel'      => null,
            'interceptors' => [],
        ];
        list($addr, $port) = self::normalizeServiceAddress($serviceAddress);
        $host = "$addr:$port";
        $stubOpts = $config['stubOpts'];
        // Set the required 'credentials' key in stubOpts if it is not already set. Use
        // array_key_exists because null is a valid value.
        if (!array_key_exists('credentials', $stubOpts)) {
            $stubOpts['credentials'] = ChannelCredentials::createSsl();
        }
        $channel = $config['channel'];
        if (!is_null($channel) && !($channel instanceof Channel)) {
            throw new ValidationException(
                "Channel argument to GrpcTransport must be of type \Grpc\Channel, " .
                "instead got: " . print_r($channel, true)
            );
        }
        try {
            return new GrpcTransport($host, $stubOpts, $channel, $config['interceptors']);
        } catch (Exception $ex) {
            throw new ValidationException(
                "Failed to build GrpcTransport: " . $ex->getMessage(),
                $ex->getCode(),
                $ex
            );
        }
    }
public static function build($serviceAddress, array $config = [])
    {
        self::validateGrpcSupport();
        $config += [
            'stubOpts'     => [],
            'channel'      => null,
            'interceptors' => [],
        ];
        list($addr, $port) = self::normalizeServiceAddress($serviceAddress);
        $host = "$addr:$port";
        $stubOpts = $config['stubOpts'];
        // Set the required 'credentials' key in stubOpts if it is not already set. Use
        // array_key_exists because null is a valid value.
        if (!array_key_exists('credentials', $stubOpts)) {
            $stubOpts['credentials'] = ChannelCredentials::createSsl();
        }
        $channel = $config['channel'];
        if (!is_null($channel) && !($channel instanceof Channel)) {
            throw new ValidationException(
                "Channel argument to GrpcTransport must be of type \Grpc\Channel, " .
                "instead got: " . print_r($channel, true)
            );
        }
        try {
            return new GrpcTransport($host, $stubOpts, $channel, $config['interceptors']);
        } catch (Exception $ex) {
            throw new ValidationException(
                "Failed to build GrpcTransport: " . $ex->getMessage(),
                $ex->getCode(),
                $ex
            );
        }
    }
public static function build ( $ serviceAddress , array $ config = [ ] ) { self :: validateGrpcSupport ( ) ; $ config += [ 'stubOpts' => [ ] , 'channel' => null , 'interceptors' => [ ] , ] ; list ( $ addr , $ port ) = self :: normalizeServiceAddress ( $ serviceAddress ) ; $ host = "$addr:$port" ; $ stubOpts = $ config [ 'stubOpts' ] ; // Set the required 'credentials' key in stubOpts if it is not already set. Use // array_key_exists because null is a valid value. if ( ! array_key_exists ( 'credentials' , $ stubOpts ) ) { $ stubOpts [ 'credentials' ] = ChannelCredentials :: createSsl ( ) ; } $ channel = $ config [ 'channel' ] ; if ( ! is_null ( $ channel ) && ! ( $ channel instanceof Channel ) ) { throw new ValidationException ( "Channel argument to GrpcTransport must be of type \Grpc\Channel, " . "instead got: " . print_r ( $ channel , true ) ) ; } try { return new GrpcTransport ( $ host , $ stubOpts , $ channel , $ config [ 'interceptors' ] ) ; } catch ( Exception $ ex ) { throw new ValidationException ( "Failed to build GrpcTransport: " . $ ex -> getMessage ( ) , $ ex -> getCode ( ) , $ ex ) ; } }
Builds a GrpcTransport.

@param string $serviceAddress
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.
@type Channel $channel Grpc channel to be used.
@type UnaryInterceptorInterface[] $interceptors *EXPERIMENTAL* Interceptor support, required until
gRPC interceptors are available.
}
@return GrpcTransport
@throws ValidationException
Builds a GrpcTransport .