Skip to content

Commit 3feb621

Browse files
committed
Attempt to appease the linter.
1 parent b39a6af commit 3feb621

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

error.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const (
3434
NotEnoughReplicas Error = 19
3535
NotEnoughReplicasAfterAppend Error = 20
3636
InvalidRequiredAcks Error = 21
37-
IllegalGeneration Error = 22
37+
IllegalGenerationErr Error = 22
3838
InconsistentGroupProtocol Error = 23
3939
InvalidGroupId Error = 24
4040
UnknownMemberId Error = 25
@@ -217,7 +217,7 @@ func (e Error) Title() string {
217217
return "Not Enough Replicas After Append"
218218
case InvalidRequiredAcks:
219219
return "Invalid Required Acks"
220-
case IllegalGeneration:
220+
case IllegalGenerationErr:
221221
return "Illegal Generation"
222222
case InconsistentGroupProtocol:
223223
return "Inconsistent Group Protocol"
@@ -426,7 +426,7 @@ func (e Error) Description() string {
426426
return "the message was written to the log, but with fewer in-sync replicas than required."
427427
case InvalidRequiredAcks:
428428
return "the requested requiredAcks is invalid (anything other than -1, 1, or 0)"
429-
case IllegalGeneration:
429+
case IllegalGenerationErr:
430430
return "the generation id provided in the request is not the current generation"
431431
case InconsistentGroupProtocol:
432432
return "the member provided a protocol type or set of protocols which is not compatible with the current group"

error_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestError(t *testing.T) {
2828
NotEnoughReplicas,
2929
NotEnoughReplicasAfterAppend,
3030
InvalidRequiredAcks,
31-
IllegalGeneration,
31+
IllegalGenerationErr,
3232
InconsistentGroupProtocol,
3333
InvalidGroupId,
3434
UnknownMemberId,

reader.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func (r *Reader) commitOffsetsWithRetry(gen *Generation, offsetStash offsetStash
164164
msgsForPartition[partition] = commitInfo.offset
165165
}
166166
}
167-
var illegalGenerationErr error
167+
var illegalGenerationErr bool
168168
for generationID, messages := range messagesToSendForGeneration {
169169
for attempt := 0; attempt < retries; attempt++ {
170170
if attempt != 0 {
@@ -173,25 +173,24 @@ func (r *Reader) commitOffsetsWithRetry(gen *Generation, offsetStash offsetStash
173173
}
174174
}
175175

176-
if commitErr := gen.CommitOffsetsForGenID(generationID, messages); commitErr == nil {
176+
if err = gen.CommitOffsetsForGenID(generationID, messages); err == nil {
177177
continue
178-
} else {
179-
// IllegalGeneration error is not retriable, but we should attempt to
180-
// perform the remaining commits
181-
if commitErr == IllegalGeneration {
182-
r.withErrorLogger(func(l Logger) { l.Printf("%v", commitErr) })
183-
illegalGenerationErr = commitErr
184-
offsetStash.removeGenerationID(generationID)
185-
} else {
186-
err = commitErr
187-
}
178+
}
179+
180+
// IllegalGeneration error is not retriable, but we should attempt to
181+
// perform the remaining commits
182+
if err == IllegalGenerationErr {
183+
r.withErrorLogger(func(l Logger) { l.Printf("%v", err) })
184+
illegalGenerationErr = true
185+
err = nil
186+
offsetStash.removeGenerationID(generationID)
188187
}
189188
}
190189
}
191190

192191
// if configured to ignore the error
193-
if illegalGenerationErr != nil && r.config.ErrorOnWrongGenerationCommit {
194-
err = illegalGenerationErr
192+
if illegalGenerationErr && r.config.ErrorOnWrongGenerationCommit {
193+
err = IllegalGenerationErr
195194
}
196195
return // err will not be nil
197196
}

reader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ func testReaderConsumerGroupRebalanceDoesNotCommitNotOwnedPartitions(t *testing.
12611261
require.NoError(t, secondReader.CommitMessages(ctx, msgsForSecondReader...))
12621262

12631263
// commit all messages the first reader received, we expect an error
1264-
require.ErrorIs(t, IllegalGeneration, firstReader.CommitMessages(ctx, allMessages...))
1264+
require.ErrorIs(t, IllegalGenerationErr, firstReader.CommitMessages(ctx, allMessages...))
12651265

12661266
// verify that no offsets have been altered
12671267
require.Eventually(t, func() bool {

0 commit comments

Comments
 (0)