Closed yurishkuro closed 6 years ago
Hi again @yurishkuro, thanks for your contribution! In my testing I've usually done this with manual calls to the gateway, like so:
$ curl -k -X POST "https://localhost:11000/api/v1/users" -H "accept: application/json" -H "Content-Type: application/json" -d '{"id": 1, "role": "ADMIN"}'
Do you think this new client functionality is necessary in light of this already being possible via the API? I would argue that if you find yourself using this for testing a lot you might write your own client to do this initial setup.
It might be possible to add this as a separate binary, or perhaps instead of this, make the flag create the client in a goroutine and immediately exit? So you wouldn't need to run the binary twice. Something like
$ grpc-example --populate
Which would start a server, start a client in a goroutine, and let the client exit after connecting and populating the server with some dummy data (to the effect of this PR). What do you think?
Do you think this new client functionality is necessary in light of this already being possible via the API?
The main idea was to include an example of a pure gRPC client, not just a REST client. There might be a way to do that with another cli tool, like prototool
, but not sure how it would work with the custom certificate in the server.
I can drop it, since it was more of an exercise for me to investigate why a similar client/server code in my app was not working.
Perhaps the one thing this would be useful for is to show an example of how a client can parse the rich error messages returned from the server. In any case, I don't think this PR is the right way to get this in, but since you've already found that this helped you, I will raise a separate issue for bringing a client example into this repo, with a separate client binary showing some example use cases.
I have added an issue to track the addition of a client example to this repo: https://github.com/gogo/grpc-example/issues/20.
+1
I found this useful to have an example of both gRPC client and a REST request.