"v1"]; } function assertConnecting($state) { assert(($state == GRPC\CHANNEL_CONNECTING || $state == GRPC\CHANNEL_TRANSIENT_FAILURE) == true); } function waitUntilNotIdle($channel) { for ($i = 0; $i < 10; $i++) { $now = Grpc\Timeval::now(); $deadline = $now->add(new Grpc\Timeval(10000)); if ($channel->watchConnectivityState(GRPC\CHANNEL_IDLE, $deadline)) { return true; } } assert(true == false); } // Set up $channel = new Grpc\Channel('localhost:50101', ['credentials' => Grpc\ChannelCredentials::createInsecure()]); // Test InsecureCredentials assert('Grpc\Channel' == get_class($channel)); // Test ConnectivityState $state = $channel->getConnectivityState(); assert(0 == $state); $channel->close(); // Test GetTarget $channel = new Grpc\Channel('localhost:50102', ['credentials' => Grpc\ChannelCredentials::createInsecure()]); $target = $channel->getTarget(); assert(is_string($target) == true); $channel->close(); // Test WatchConnectivityState $channel = new Grpc\Channel('localhost:50103', ['credentials' => Grpc\ChannelCredentials::createInsecure()]); $now = Grpc\Timeval::now(); $deadline = $now->add(new Grpc\Timeval(100*1000)); $state = $channel->watchConnectivityState(1, $deadline); assert($state == true); unset($now); unset($deadline); $channel->close();