Skip to content

fix: handle StartOffset when no consumer group set #1386

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,6 @@ type ReaderConfig struct {
// non-zero, it must be set to one of FirstOffset or LastOffset.
//
// Default: FirstOffset
//
// Only used when GroupID is set
StartOffset int64

// BackoffDelayMin optionally sets the smallest amount of time the reader will wait before
Expand Down Expand Up @@ -697,14 +695,19 @@ func NewReader(config ReaderConfig) *Reader {
version = 1
}

startOffset := FirstOffset
if config.StartOffset != 0 {
startOffset = config.StartOffset
}

stctx, stop := context.WithCancel(context.Background())
r := &Reader{
config: config,
msgs: make(chan readerMessage, config.QueueCapacity),
cancel: func() {},
commits: make(chan commitRequest, config.QueueCapacity),
stop: stop,
offset: FirstOffset,
offset: startOffset,
stctx: stctx,
stats: &readerStats{
dialTime: makeSummary(),
Expand Down