Skip to content

Commit 34e013e

Browse files
committed
Some changes in constants.
1 parent 5744d1d commit 34e013e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

conn.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import (
1717
var (
1818
errInvalidWriteTopic = errors.New("writes must NOT set Topic on kafka.Message")
1919
errInvalidWritePartition = errors.New("writes must NOT set Partition on kafka.Message")
20+
21+
undefinedGenerationId int32 = -1
2022
)
2123

2224
// Conn represents a connection to a kafka broker.
@@ -184,7 +186,7 @@ func NewConnWith(conn net.Conn, config ConnConfig) *Conn {
184186
offset: FirstOffset,
185187
requiredAcks: -1,
186188
transactionalID: emptyToNullable(config.TransactionalID),
187-
generationId: -1,
189+
generationId: undefinedGenerationId,
188190
}
189191

190192
c.wb.w = &c.wbuf

reader.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (r *Reader) commitOffsetsWithRetry(gen *Generation, offsetStash offsetStash
156156
for partition, commitInfo := range partitionsInfo {
157157
// if there is a generation and it is different than the current
158158
// it means there was a rebalance
159-
if commitInfo.generationId != -1 {
159+
if commitInfo.generationId != undefinedGenerationId {
160160
if gen.ID == commitInfo.generationId {
161161
msgsForTopic[partition] = commitInfo.offset
162162
} else {
@@ -855,7 +855,7 @@ func (r *Reader) FetchMessage(ctx context.Context) (Message, error) {
855855
r.mutex.Lock()
856856

857857
if !r.closed && r.version == 0 {
858-
r.start(-1, r.getTopicPartitionOffset())
858+
r.start(undefinedGenerationId, r.getTopicPartitionOffset())
859859
}
860860

861861
version := r.version
@@ -1076,7 +1076,7 @@ func (r *Reader) SetOffset(offset int64) error {
10761076
r.offset = offset
10771077

10781078
if r.version != 0 {
1079-
r.start(-1, r.getTopicPartitionOffset())
1079+
r.start(undefinedGenerationId, r.getTopicPartitionOffset())
10801080
}
10811081

10821082
r.activateReadLag()

0 commit comments

Comments
 (0)