GoLang Hands-on with gRPC-Unary

Part #1.) :- Steps to demonstrate the basic setup :-

brew install clang-format
brew install protobuf
go get -u google.golang.org/grpc
brew install protoc-gen-go
brew install protoc-gen-go-grpc

Part #2.) :- We are now setting up the gRPC based server :-

go mod init github.com/adityagoel123/grpc-aditya-learning
  • client
  • server
  • proto
protoc -Igreet/proto --go_opt=module=github.com/adityagoel123/grpc-aditya-learning --go_out=. --go-grpc_opt=module=github.com/adityagoel123/grpc-aditya-learning --go-grpc_out=. greet/proto/*.proto
  • At line #18, we are listening on the default TCP port i.e. 50051. This is also a default port at which gRPC server usually runs.
  • At line #27, we are launching a new-server through gRPC.
  • At line #28, we are registering our gRPC server with the Service, so that, it can start serving the traffic on the same.
go mod tidy
go build -o bin/greet/server ./greet/server
./bin/greet/server

Part #3.) :- We are now setting up the gRPC based client :-

  • At line #13, we are setting-up gRPC-connection in an un-secured manner.
  • At line #19, we are indicating our intent that, gRPC-connection shall be closed, once the entire processing of main function is done with.
go build -o bin/greet/client ./greet/client
./bin/greet/client

--

--

--

Software Engineer for Big Data distributed systems

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Mistakes I Made Writing a PAC-MAN Game(and How I Fixed Them)

How to land your first developer job with ZERO experience (1/2)

Don’t ever again write // TODOs

Adventures in GameDev with GameDevHQ! Day 13, an introduction to Physics in Unity.

Deployment by using CI/CD Automation on top of Kubernetes.

Deploying a Serverless REST API (FaaS) with Python — Part 1

Memento Design Pattern

User RBAC on Kubernetes Simplified

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
aditya goel

aditya goel

Software Engineer for Big Data distributed systems

More from Medium

A Guide To Higher-Kinded Type Classes with Golang

Catching Go errors with errors.Is()

Valet, a job queuing and async task running service packed in a Go module

Creating a minimal container image for a Go application