/go-grpc

gRPC server implemented with Go

Primary LanguageGo

gRPC Server implementation with Golang

How gRPC works

Tools used for

Protoc Plugins

  • protoc-gen-go protoc-gen-go is a plugin for the Google protocol buffer compiler to generate Go code.
  • protoc-gen-go-grpc This tool generates Go language bindings of services in protobuf definition files for gRPC.

Generate Go Code form proto file

protoc \
--go_out=logger \
--go_opt=paths=source_relative \
--go-grpc_out=logger \
--go-grpc_opt=paths=source_relative \
logger.proto
  • Generates logger/logger_grpc.pb.go with protoc-gen-go-grpc
  • Generates logger/logger.pb.go with protoc-gen-go

Starts the server

go run main.go

Starts de UI in order to send log messages to the server

grpcui \
-plaintext \
-use-reflection=false \
-proto=logger.proto \
localhost:8089

Visit localhost:8089 and send log messages to the server.

You can choose the different methods to execute

Make a request to the server to get all app logs messages

grpcurl \
-plaintext \
-use-reflection=false \
-proto=logger.proto \
-d '{"name": "app"}' \
localhost:8089 Logger.GetLogsByApp

Special thanks to @ossan-dev to the workshop in Nerdearla 2023