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

How to use a various database with Ruby on Rails

JVM Tutorial - Java Virtual Machine Architecture Explained for Beginners

Daily Progression — Setting Up Transitions Between Animations

ElasticSearch with a SMILE

Tips on REST API Error Response Structure

Be original in execution.

More Productive SQL Part 1

Multiple Request/Response examples for Swagger UI in ASP.NET core

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

Why you should use private custom type keys for context?

Fast Golang router with error handling

Learn Go: Concurrency

Tutorial: Building a Golang application Docker image