-
Notifications
You must be signed in to change notification settings - Fork 3
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
fixed reader logic to support chunked messages #2
Conversation
67040d1
to
c9bbfa9
Compare
Signed-off-by: Vladyslav Diachenko <vlad.diachenko@grafana.com>
c9bbfa9
to
5d57ef7
Compare
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 working on this. I have put a couple of thoughts together testing/reading to your code.
In general I feel you would need to add a couple more comments to make sure the code is easily understood/read at a later point. So for example make it clear that the 128 fragment limit is coming from the protocol itself: https://docs.graylog.org/docs/gelf
I also think there are a couple of edge cases that we need to cover, as pretty much anything can happen to UDP packets on the network. I would also love to see cases with modified data covered by the tests.
Nit: I also wonder if "assembler" is the best name, I think "defragmentation" is quite common thinking about networking protocols.
Signed-off-by: Vladyslav Diachenko <vlad.diachenko@grafana.com>
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 incorporating my feedback. I think there are only minor things now. See my suggestions inline.
I think it's also worth running golangci-lint
. As those look all relevant:
gelf/reader_test.go:185:8: ineffectual assignment to err (ineffassign)
conn, err := net.DialUDP("udp", nil, addr)
^
gelf/reader_test.go:74:4: SA5001: should check returned error before deferring conn.Close() (staticcheck)
defer conn.Close()
^
gelf/reader_test.go:186:2: SA5001: should check returned error before deferring conn.Close() (staticcheck)
defer conn.Close()
^
gelf/reader.go:91:2: SA4006: this value of `cBuf` is never used (staticcheck)
cBuf := make([]byte, ChunkSize)
Yep, thanks. I have fixed all issues in
|
Signed-off-by: Vladyslav Diachenko <vlad.diachenko@grafana.com>
Yes do not worry about pre-existing linting issues 🙂 |
Signed-off-by: Vladyslav Diachenko <vlad.diachenko@grafana.com>
Signed-off-by: Vladyslav Diachenko <vlad.diachenko@grafana.com>
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.
Nice one. Thanks for addressing my suggestions so patiently 🙂
LGTM 🚀
Fixed reader logic to support the case when between chunks of one message the reader receives the chunks from another message or not chunked message.
more info grafana/loki#5644
Notes for Reviewers