Open mthenw opened 6 years ago
Instead of using a binary representation over HTTP I would use end to end binary stream.
bson (binary json): packing and unpacking is very simple, it's just JSON in a binary representation, it's schemaless which doesn't allow much optimizations.
protobuf (protocol buffers): require a schema which allows lots of optimizations. Many languages are supported by the SDK. The hidden cost is the schema management.
gRPC: RPC using protobuf over HTTP2. I would by experience recommend this one. Keep in mind that it uses long-living connections.
@xtuc the goal is to allow function (e.g. AWS Lambda) returning binary files. Also, it has to be easy to achieve with standard lib across different languages. Not sure if your proposed solutions accomplish that?
Ok, sorry I didn't know it was to communicate with lambdas.
As I said, bson is really a simple packing technique, it should be implementable in every languages.
@xtuc the problem is that it requires external libraries. I know that base64 is not perfect but at least it's "universal". In the future, we may support compression between EG <> FaaS.
Optionally, instead of adding another field in the response object we can just detect binary payload based on returned content type.
Current implementation support HTTP responses via special JSON object schema. Right now only string is supported as a response body. EG needs to support also binary responses. Requirements:
Possible solution
isBinary
flag and base64 encodingRight now the supported object looks like this:
The proposition is to support additional flag
isBinary
that will indicate thatbody
is base64 encoded string that carries a binary payload. EG will decode it and return a binary response to the requester. We already pass a Base64 string to a function in case of binary input data so this solution is "symmetrical".Node.js Example
Python Example
cc @brianneisler @DavidWells @nikgraf