lileio / lile

Easily generate gRPC services in Go ⚡️
MIT License
1.5k stars 88 forks source link

Adding Client-side code generators and Ask Advise for dependent servers #67

Open danielkurniadi opened 4 years ago

danielkurniadi commented 4 years ago

Let's take a look at your slack example and say we have two server:

  1. ServerOne implements Announce() via gRPC interface (say to announce notif to slack)
  2. ServerTwo needs a server to announce something to slack. It needs to call ServerOne

Well then, I build ServerOne with lileio/lile and get an autogenerated code in Go. Neat and pretty.

How about ServerTwo? Hmmm its a bit tedious because:

  1. To commnicate with ServerOne, developer need to read and understand the proto file of ServerOne. Good thing if ServerOne developers kindly have an API docs.
  2. Then come changes in ServerOne proto file which change the comminication contract between ServerOne and ServerTwo. Then these changes also affect the dependent microservice (ServerTwo)

Ideas

There are two ideas for Go developer to resolve this:

  1. Versioning of API: ServerOne do two version of API: the old schema and new schema. Allowing ServerTwo to slowly migrate.
  2. Autogenerated Client-side: ServerOne can give its protofile to ServerTwo and we can build a code generator for client side.

I want to highlight on the (2) Ideas here and whether it should be supported, what are the Pros and Cons.

Pros

Cons

danielkurniadi commented 4 years ago

Hence, what do you think? If you say No to this feature, can you help me suggest what are the neat and efficient way to build a client-side Go application that can communicate with ServerTwo but minimize coupling to ServerOne gRPC schema as much as possible. Thanks!