Skip to content
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

consume: add Avro support #25

Merged
merged 1 commit into from
Mar 31, 2020
Merged

consume: add Avro support #25

merged 1 commit into from
Mar 31, 2020

Conversation

gillesfabio
Copy link

@gillesfabio gillesfabio commented Mar 16, 2020

  • Add Avro support to consume command
  • Extra: remove some unused/dead code
  • Extra: rename kt -> hkt

@gillesfabio gillesfabio requested review from rogpeppe and tealeg March 16, 2020 07:37
Copy link

@tealeg tealeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Couple of small points, I'll let @rogpeppe speak to any specific suggestions about the structure of hkt as he know it better.

if body == nil {
return nil, fmt.Errorf("cannot decode schema id")
}
// TODO: cache the schema
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO's are great, but I like them to be converted into issues, so that they can be scheduled and not forgotten when we don't regularly visit the code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Done (#26).

var enc func([]byte) string
switch typ {
case "json":
return func(data []byte) (json.RawMessage, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point I'd probably consider pushing the generation of this function (and the one like it below) out to named functions of their own, just because the switch statement is getting a bit long.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I will do it in another PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to "simplify" the switch using a map with dedicated method per type: 0e4a242 If you think it's okay, I can propose the PR (it's based on this branch).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I don't think it's too unwieldy currently - not sure that splitting it up will help readability.

@gillesfabio gillesfabio mentioned this pull request Mar 16, 2020
Copy link

@rogpeppe rogpeppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks! I'd really like to see an end-to-end test in testdata, but that's hard without the produce side, I guess. I've a few minor comments and suggestions, but otherwise LGTM.

consume.go Outdated Show resolved Hide resolved
consume.go Outdated Show resolved Hide resolved
consume.go Outdated Show resolved Hide resolved
var enc func([]byte) string
switch typ {
case "json":
return func(data []byte) (json.RawMessage, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I don't think it's too unwieldy currently - not sure that splitting it up will help readability.

consume_test.go Outdated Show resolved Hide resolved
@gillesfabio gillesfabio force-pushed the consume-avro-support branch from ceaf6fd to 73dc2ee Compare March 30, 2020 15:44
@gillesfabio gillesfabio requested a review from rogpeppe March 30, 2020 15:45
Copy link

@rogpeppe rogpeppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM.

@gillesfabio gillesfabio merged commit 71a86be into master Mar 31, 2020
@gillesfabio gillesfabio deleted the consume-avro-support branch March 31, 2020 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants