-
Notifications
You must be signed in to change notification settings - Fork 15
Fix codec handling #464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix codec handling #464
Conversation
0fa78b6 to
c194838
Compare
This patch fixes how the encoding codec is handled across the entire codebase. Prior to this commit, support for codecs other than JSON was incomplete, mainly since the code assumed that all function output must be valid . Proper handling of codecs involves: * Validating JSON as the canonical input to function runner. * Encoding from JSON to a given codec if needed * Encoding to JSON from the function's output if needed and ensuring to keep save any encoding errors when needed. In order to achieve proper codec handling, I opted to encapsulate the details related to input and output bytes in a container (`BytesContainer`), which can either hold input or output bytes, and simiarly perform all the byte-level operations needed for reporting, such as calculating the length, presenting a human-readable representation, etc. This commit also adds the proper tests for each codec.
c194838 to
9bfb777
Compare
src/lib.rs
Outdated
| /// JSON input. | ||
| Json, | ||
| /// Raw input, no validation, passed as-is. | ||
| #[default] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have expected Json to be the default based on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the same as echo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #464 (comment)
| edition = "2021" | ||
|
|
||
| [dependencies] | ||
| rmpv = "1.3.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I wanted to decode in this test, but forgot about it. I've updated the test to do the decoding.
d85d2b6 to
1d78999
Compare
lopert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been tophatting this by stacking my branch on top of it and using the new provider that needs messagepack. 👍 #463
Co-authored-by: Alex Bradley <alexandre.bradley@shopify.com>
This patch fixes how the encoding codec is handled across the entire codebase.
Prior to this commit, support for codecs other than JSON was incomplete, mainly since the code assumed that all function output must be valid JSON.
Proper handling of codecs involves:
In order to achieve proper codec handling, I opted to encapsulate the details related to input and output bytes in a container (
BytesContainer), which can either hold input or output bytes, and similarly perform all the byte-level operations needed for reporting, such as calculating the length, presenting a human-readable representation, etc.This commit also adds the proper tests for each codec.