katzien / go-structure-examples

Examples for my talk on structuring go apps
MIT License
2.35k stars 287 forks source link

gRPC example #10

Closed vic3lord closed 3 years ago

vic3lord commented 5 years ago

First off, this is a great repo which I use often as a reference.

I adopted the DDD option in a few services with only REST APIs and would like to add gRPC support but:

  1. Where would you put the .proto files
  2. Would the protobuf service conflict the go interface service we already use
  3. How do you implement a repository interface for AddBeer without having 2 structs of storage implementing the same methods.
    • gRPC: func (s *StorageA) AddBeer(ctx, *pb.BeerRequest)
    • HTTP: func (s *StorageB) AddBeer(beer struct goes here)

Thanks 🎉

smgladkovskiy commented 5 years ago

With your permission, I will expand the question.

What if there is Reviewer object (we need to extract user data from Review and preserve it separately) and it should be stored strictly in SQL database storage (postgres|mysql|whatever, but it should be db)?

How to organize the listing and updating services and repositories? Should there be different services and repos for the same actor (listener)? @katzien ?