Tecsisa/foulkon

RFC: Adding a GRPC API

srenatus opened this issue ยท 5 comments

Hi there. We're transitioning our internal services to use GRPC (instead of HTTP/REST). Thus, I'd like to contribute a GRPC interface to Foulkon's worker.

What do you think? Would you appreciate the addition? Also, I don't just want to throw a huge junk of code over the fence, but rather incrementally add the functionality.

What does this look like?

  • a .proto definition for the service's methods
  • generated go code (using protoc-gen-go)
  • another wrapper package, grpc, around the methods defined in api, implementing the stubs generated from the .proto (this is akin to http)

Example: dex

This is how dex does it:

  • its proto, excerpt:
    // CreateClientReq is a request to make a client.
    message CreateClientReq {
      Client client = 1;
    }
    
    // CreateClientResp returns the response from creating a client.
    message CreateClientResp {
      bool already_exists = 1;
      Client client = 2; 
    }
    // ...
    
    service Dex {
      // CreateClient creates a client.
      rpc CreateClient(CreateClientReq) returns (CreateClientResp) {};
      // ...
    }
  • the generated code
  • the defined methods:
    func (d dexAPI) CreateClient(ctx context.Context, req *api.CreateClientReq) (*api.CreateClientResp, error) { /* ...  */ }

Notes

  • Generating the code also gives us a client library, which would fix #64.
  • Authenticating requests would, for GRPC, use the GRPC metadata -- containing a JWT token, or a special header (depending on the configured authenticators) -- in the same way it works for the HTTP API.

@srenatus, we have to review this, it's a huge change as you said, we will tell you something soon. Thanks for your comments.

@rsoletob Thanks! I'm looking forward to hear from you. Happy to clarify stuff, I've also just re-joined the gitter room for real-time comms.

What I've forgotten to point out is that there's some potential here to eventually use grpc-gateway to generate the REST handlers, which would then reduce the overall amount of custom code again ๐Ÿ˜‰

The cool thing about GRPC is that it create a language-independent API. CoreOS etcd, Kubernetes and Docker migrate to use GRPC. I would love to see this as part of the project, too?

@srenatus @chris-rock we agree with you, gRPC seems like a good feature. We dont have much experience working with gRPC, but we'll improve our knowledge about it. In short, we would love to add this function to foulkon.
We let this issue open to track the progress of this feature.