Skip to content

Commit

Permalink
Use RequestTimedOut on empty batch instead of errShortRead (segmentio…
Browse files Browse the repository at this point in the history
…#315)

This should better capture the spirit of the empty batch by
surfacing the error code that indicates the broker wasn't able to
return new messages before the max wait time passes.
  • Loading branch information
Steve van Loben Sels authored Jul 22, 2019
1 parent ad7818b commit c98551b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion message.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (r *messageSetReader) readMessage(min int64,
val func(*bufio.Reader, int, int) (int, error),
) (offset int64, timestamp int64, headers []Header, err error) {
if r.empty {
return 0, 0, nil, errShortRead
return 0, 0, nil, RequestTimedOut
}
switch r.version {
case 1:
Expand Down
4 changes: 2 additions & 2 deletions message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func TestMessageSetReaderEmpty(t *testing.T) {
if headers != nil {
t.Errorf("expected nil headers, got %v", headers)
}
if err != errShortRead {
t.Errorf("expected errShortRead, got %v", err)
if err != RequestTimedOut {
t.Errorf("expected RequestTimedOut, got %v", err)
}

if m.remaining() != 0 {
Expand Down

0 comments on commit c98551b

Please sign in to comment.