Basic grpc "Hello world like" services, unary and stream services good for learning purposes.
224
This is a GRPC server with basic features to support my laboratories, written articles, and videos it provides a sample of unary call, client streaming, server streaming and bidirectional streaming. All the samples are "Hello world like" but once you have the project structure is possible to extend it to any purpose.
visit my portfolio to find more about many topics.
the image src code is available in my github
How to use the image:
docker run --rm --name grpc -p 50051:50051 getjv/go-grpc-server
gRPCurl is a super handy tool, and the main commands are:
grpcurl -plaintext [::]:50051 list – lists the available services.grpcurl -plaintext [::]:50051 describe <ServiceName> – provides more information about the available service.grpcurl -plaintext -d '<JSON-Payload>' [::]:50051 <ServiceName.MethodName> – makes a direct call to a method with a payload.Hello sample: it's a unary call with single request single response.
grpcurl -plaintext -d '{"name": "jhonatan"}' [::]:50051 helloworld.Greeter.SayHello
Server Streaming sample: it's a server streaming sample with 1 request and 10 messages from server
grpcurl -d '{"name": "Cliente"}' -plaintext localhost:50051 helloworld.Greeter/StreamGreetings
Client Streaming sample: it's a client streaming sample with 10 client requests and 1 message from server Here the steps are a bit different:
grpcurl -plaintext -d @ localhost:50051 helloworld.Greeter/EchoGreetings
enter:{"name": "Alice"}
{"name": "Bob"}
{"name": "Charlie"}
CTRL+D to notify all was sent. Server will send you the final confirmation.Bi-directional streaming: this is the most advanced sample an open channel to both sides keeping interacting to test execute:
grpcurl -plaintext -d @ localhost:50051 helloworld.Greeter/OpenGreetings
enter:{"name": "Alice"}
enter Server will send you a confirmation.CTRL+D to notify you are done.Content type
Image
Digest
sha256:609980869…
Size
10.7 MB
Last updated
over 1 year ago
docker pull getjv/go-grpc-server