Skip to content

amulyakashyap09/golang_grpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gRPC based Implementation in Golang

This project helps you in understanding gRPC based concepts and it's implementation
NOTE : Keep all proto files in $GOPATH/protofiles under their project names directory (best practices)

Installation

mkdir $GOPATH/protofiles 

mkdir $GOPATH/protoFiles/grpc_tutorial

Copy this file :

https://github.com/amulyakashyap09/golang_grpc/blob/master/users.proto to $GOPATH/protoFiles/grpc_tutorial

RUN this command :

protoc -I /protofiles /protofiles/grpc_tutorial/users.proto --gout=plugins=./grpc_tutorial

  • Above command will generate the grpc_tutorial named directory under $GOPATH/src
  • With nested folder name pb which contains a file named users.pb.go
  • This file is generated by proto compiler
cd $GOPATH/src/grpc_tutorial
mkdir client server
touch client/main.go server/main.go server/data.go

Now you have your project strcuture ready.

Copy files to their respective directories :

Now we are done with project and its content.

Usage

BUILD & EXECUTE SERVER :

Build the server : go install grpc_tutorial/server

Execute the server binary : $GOPATH/bin/server

BUILD & EXECUTE CLIENT :

Build the client : go install grpc_tutorial/client

Execute the client binary : $GOPATH/bin/client -o <int_value> with options

Now after executing client you have to pass inputs over cli

  • 1 sending metadata to server | $GOPATH/bin/client -o 1
  • 2 Fetching User by ID | $GOPATH/bin/client -o 2
  • 3 Fetch all users | $GOPATH/bin/client -o 3
  • 4 Save user to file | $GOPATH/bin/client -o 4
  • 5 Save all users to file | $GOPATH/bin/client -o 5

And you'll see output everytime on the terminal when any command executes.

Version

  • 0.0.1 | basic implementation of gRPC in golang

Author

About

A grpc based implementation for client and server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages