Skip to content

Commit

Permalink
Check on min and max bytes after their proper set (segmentio#166)
Browse files Browse the repository at this point in the history
ppatierno authored and achille-roussel committed Jan 4, 2019
1 parent a28af3c commit 5715945
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions reader.go
Original file line number Diff line number Diff line change
@@ -1012,10 +1012,6 @@ func NewReader(config ReaderConfig) *Reader {
panic(fmt.Sprintf("partition number out of bounds: %d", config.Partition))
}

if config.MinBytes > config.MaxBytes {
panic(fmt.Sprintf("minimum batch size greater than the maximum (min = %d, max = %d)", config.MinBytes, config.MaxBytes))
}

if config.MinBytes < 0 {
panic(fmt.Sprintf("invalid negative minimum batch size (min = %d)", config.MinBytes))
}
@@ -1069,6 +1065,10 @@ func NewReader(config ReaderConfig) *Reader {
config.MinBytes = config.MaxBytes
}

if config.MinBytes > config.MaxBytes {
panic(fmt.Sprintf("minimum batch size greater than the maximum (min = %d, max = %d)", config.MinBytes, config.MaxBytes))
}

if config.MaxWait == 0 {
config.MaxWait = 10 * time.Second
}

0 comments on commit 5715945

Please sign in to comment.