A simple gRPC Unary API which uses Repository pattern.
- to run the grpc server, run
go run main.go
in thecmd
directory to run themain.go
file. - run
go run main.go
in theclient/user
directory to run the grpc client forUser
detail(GetUser
). - run
go run main.go
in theclient/users
directory to run the grpc client for a list ofUser
details(GetUsers
). - to run the tests, run
go test
in thecmd
directory to run themain_test.go
file.
- I've used Repository pattern in this project to create a layer between database specific logic and business logic in the app.
- I've used an in-memory repository implementation.
- Using this pattern, we can treat repositories as adapters which can be changed in the future without having to touch the business logic(handlers). For example, to use MySQL in future, we can create a MySQL repository and use it instead of the in-memory repository.