-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
adds decode/3 with format option #70
adds decode/3 with format option #70
Conversation
23d93b1
to
1163f20
Compare
Hi @mw23 👋🏼 Thanks a lot for your contribution, I appreciate it! Let me think a bit about proposed changes over weekends |
Thanks for the patience @mw23 I've read the code one more time and I think I have something to rise.
At the same time, I think, we should be able to enforce decoding for the As a suggestion, maybe we should come up with UPD: Also by |
1163f20
to
4d93474
Compare
Hi @Strech, thank you for considering this. I see your point and agree that separate function(s) might be a way to go to make this cleaner so I went ahead and added To your argument about handling this as exception in Please let me know what you think. |
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.
Thanks for your effort. I would like to request one thing in addition to the comments.
Can you two made up calls here to validate an external interface
test/avrora/encoder_test.exs
Outdated
@@ -732,4 +788,8 @@ defmodule Avrora.EncoderTest do | |||
defp payment_json_schema do | |||
~s({"namespace":"io.confluent","name":"Payment","type":"record","fields":[{"name":"id","type":"string"},{"name":"amount","type":"double"}]}) | |||
end | |||
|
|||
defp numeric_transfer_json_schema do | |||
~s({"namespace":"io.confluent","name":"numeric_transfer","type":"record","fields":[{"name":"link_is_enabled","type":"boolean"},{"name":"updated_at","type":"int"},{"name":"updated_by_id","type":"int"}]}) |
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.
May I ask you to follow the guideline for naming (it's not so important here, but oh my OCD) and rename the schema name to NumericTransfer
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.
done
test/avrora/encoder_test.exs
Outdated
@@ -706,6 +753,10 @@ defmodule Avrora.EncoderTest do | |||
119, 32, 97, 114, 101, 32, 121, 111, 117, 63, 0>> | |||
end | |||
|
|||
defp numeric_transfer_plain_message_0 do |
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.
Maybe to emphasize the issue we can name it numeric_transfer_plain_message_with_fake_magic_byte
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.
done
Co-authored-by: Sergey Fedorov <oni.strech@gmail.com>
@Strech Thanks for your review. I incorporated the changes you requested. |
@mw23 Thanks a lot for such a quick update. Everything looks good to me. I will merge it on a Sunday 💙 |
@Strech - that's great news! Thank you! |
This fixes a bug where decoding fails for a data that was encoded with a supplied
schema_name
and:plain
formatIf the encoded message starts with the magic byte (0x00) due to the data that was encoded, the wrong codec is selected by
https://github.com/Strech/avrora/blob/master/lib/avrora/encoder.ex#L76
when decoding it later.
This causes the decoding to fail sporadically dependent on the encoded data.
I propose to fix this by including an optional
format
argument to thedecode
function.Example: New test case that broke before adding the
format: plain
parameter