class Channel (View source)

Class Channel

Methods

__construct(string $target, array $args = [])

Construct an instance of the Channel class. If the $args array contains a "credentials" key mapping to a ChannelCredentials object, a secure channel will be created with those credentials.

string
getTarget()

Get the endpoint this call/stream is connected to

int
getConnectivityState(bool $try_to_connect = false)

Get the connectivity state of the channel

bool
watchConnectivityState(int $last_state, Timeval $deadline_obj)

Watch the connectivity state of the channel until it changed

close()

Close the channel

Details

__construct(string $target, array $args = [])

Construct an instance of the Channel class. If the $args array contains a "credentials" key mapping to a ChannelCredentials object, a secure channel will be created with those credentials.

Parameters

string $target

The hostname to associate with this channel

array $args

The arguments to pass to the Channel (optional)

Exceptions

InvalidArgumentException

string getTarget()

Get the endpoint this call/stream is connected to

Return Value

string

The URI of the endpoint

int getConnectivityState(bool $try_to_connect = false)

Get the connectivity state of the channel

Parameters

bool $try_to_connect

try to connect on the channel

Return Value

int

The grpc connectivity state

Exceptions

InvalidArgumentException

bool watchConnectivityState(int $last_state, Timeval $deadline_obj)

Watch the connectivity state of the channel until it changed

Parameters

int $last_state

The previous connectivity state of the channel

Timeval $deadline_obj

The deadline this function should wait until

Return Value

bool

If the connectivity state changes from last_state before deadline

Exceptions

InvalidArgumentException

close()

Close the channel