Writing a php client using the gRPC HealthCheck proto

30 views
Skip to first unread message

deepakk...@wepay.com

unread,
Oct 29, 2020, 8:53:57 PM10/29/20
to grpc.io
Hi,
I am hoping to find any information on how I can create a simple Healthcheck client in php against the internally defined proto (https://github.com/grpc/grpc/blob/master/src/proto/grpc/health/v1/health.proto).
We already have a working environment for gRPC clients using the model and libs defined here : https://github.com/grpc/grpc-php. However I am not certain if there is a documented way to either generate the protos defined in io/grpc or use them as is in php.
To further clarify,
I am hoping to do some thing like the below snippet in PHP

import io.grpc.health.v1.HealthCheckRequest;
import io.grpc.health.v1.HealthCheckResponse;
import io.grpc.health.v1.HealthGrpc;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;

public class HealthcheckImplClient {
      public static void main(String[] args) {

     ManagedChannel ch = ManagedChannelBuilder.forAddress("localhost", 8012)
     .usePlaintext()
      .build();
  HealthGrpc.HealthBlockingStub hclient = HealthGrpc.newBlockingStub(ch);
  HealthCheckRequest req = HealthCheckRequest.newBuilder().build();
  HealthCheckResponse resp = hclient.check(req);
  System.out.println(resp.getStatus());

  ch.shutdown();
  }
}


Appreciate any help regarding this. 


Thanks,
Deepak

Stanley Cheung

unread,
Oct 30, 2020, 8:10:07 PM10/30/20
to deepakk...@wepay.com, grpc.io
You can check this section https://grpc.io/docs/languages/php/quickstart/#php-protoc-plugin in the grpc.io website to see how you can use the PHP grpc plugin to generate a stub client from your proto.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/c6e514f1-3aba-446e-871d-fb587c4569d4n%40googlegroups.com.

deepakk...@wepay.com

unread,
Oct 30, 2020, 8:19:35 PM10/30/20
to grpc.io
Thanks, but this information pertains to generating our custom proto definitions which we are already doing.
My question was more focused on how or if I even need to generate the clients for the internally available https://github.com/grpc/grpc/blob/master/src/proto/grpc/health/v1/health.proto

I want to know if we can avoid duplicating/sourcing this health proto in our internal repos in order to generate the code

Reply all
Reply to author
Forward
0 new messages