package
0.0.0-20210510044125-d944f765a1e2
Repository: https://github.com/rajch/contacts.git
Documentation: pkg.go.dev
# README
grpcserver
This demonstrates:
- an implementation of a GRPC server interface generated by the
protoc
compiler - the repository pattern
GRPC Server implementation
The contactServer
struct defined in the grpcserver.go file implements the ContactServiceServer
interface generated by the protoc
compiler. An important detail is the embedding of a struct called grpc.UnimplementedContactServiceServer
. The Go tooling for protoc
includes this detail to ensure forward compatibility when modifying GRPC definitions.
Repository pattern
The GRPC server can store contact data in a json file or a sqlite database. The code uses the Repository interface provided by the contacts package. You can choose the actual repository inmplementation by changing the getrepo
function defined at the end of grpcserver.go.