Skip to content

Just a simple example of a gRPC service written in Go

Notifications You must be signed in to change notification settings

vshulcz/grpc-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gRPC Calculator

gRPC Calculator – just a simple example of a gRPC service written in Go. You'll find a few standard math operations implemented (Add, Subtract, Multiply, Divide), and it's all wrapped up with some middleware for logging and recovery

Protobuf contract

https://github.com/vshulcz/grpc-protos

Getting Started

  1. Clone the repo:

    git clone https://github.com/vshulcz/grpc-calculator.git
    cd grpc-calculator
  2. Install dependencies:

    go mod tidy
  3. Compile the project:

    go build -o calculator ./cmd/calculator
  4. Run the gRPC server:

    ./calculator --config="config/dev.yaml"
  5. Test it out with grpcurl: Install grpcurl:

    brew install grpcurl

    To see the available services:

    grpcurl -plaintext localhost:5105 list

    To call the Add method:

    grpcurl -plaintext -d '{"number1": 5, "number2": 3}' localhost:5105 calculator.Calculator.Add
  6. Run the tests:

    go test ./... -v

Configuration

The configuration is stored in YAML files (e.g., config/dev.yaml), and we load it using cleanenv.

About

Just a simple example of a gRPC service written in Go

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages