README ¶
Go CRUD gRPC
CRUD example to learn how gRPC works in Go with MongoDB
Prerequisite
- Go, follow this official installation guide
- MongoDB, follow this instruction from it's official page
- gRPC, follow this quick start guide for Go specific
How to run gRPC server
- clone this repository
git clone git@github.com:salprima/gocrud-grpc.git
- execute
go mod tidy
to add missing and remove unused modules dependencies - adjust
configs/default-config.yml
according to your local environment - start gRPC server by executing
make run-grpc-server
- if everything okay, you will see something like the following in your terminal
$ make run-grpc-server
go run cmd/grpc-server/main.go
2020/05/25 19:13:26 loading config file default-config.yml
2020/05/25 19:13:26 Starting up GRPC server...
2020/05/25 19:13:26 Creating connection to database...
2020/05/25 19:13:26 Connected to database...
How to run gRPC client
- follow steps 1-3 on How to run gRPC server above
- make sure gRPC server up and running
- run gRPC client by executing
make run-grpc-client
- if all good, you will see log in your terminal simulating all gRPC methods as describe in
api/protobuf/user.proto
What to expect?
- understand how gRPC client & server implementation in Go
- know how MongoDB works within Go using MongoDB Go Driver
- a little example of how Viper works to deal with configuration file
- TIPS: you can run gRPC client using another language you loved, see available quick start guide here
License
This project is licensed under the MIT License, see the LICENSE file for details.
Click to show internal directories.
Click to hide internal directories.