appcelerator-archive / ampnext-discussion

This is a placeholder repo for discussions and prototyping around the next version of amp.
0 stars 0 forks source link

use protocol buffers and grpc streaming for cluster plugins #12

Open subfuzion opened 7 years ago

subfuzion commented 7 years ago

Proposal

Cluster plugins should provide a standard service interface for plugin lifecycle operations with grpc streaming responses for structured messages that relay asynchronous status as well as stdio/stderr packets.

Rationale

The current plugin model is simple and straightforward; plugins accept commands, arguments, and options, and stream responses over stdio and stderr. However, this requires extra code on the client for packaging up data to send to the plugin and command line parsing support in each plugin; for returning data, a structured message format is needed to interleave status messages into the stdout/stderr streams, and manual JSON marshaling/unmarshaling (and currently, this is not consistently applied, leading to parse errors on the client).

It is straightforward and more robust to define a standard message format for requests and streaming responses to handle these needs.

The client should be able to start a plugin on an available ephemeral port for the entirety of a cluster managment operation and this should be transparent to the user.

References

https://grpc.io/docs/guides/concepts.html#server-streaming-rpc https://grpc.io/docs/tutorials/basic/go.html#server-side-streaming-rpc https://grpc.io/docs/tutorials/basic/go.html#server-side-streaming-rpc-1