consumer: return rebalance event via Poll() when appRebalanceEnable && no RebalanceCb #1472
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Return the rebalance event from
handleRebalanceEvent
whengo.application.rebalance.enable == true
and noRebalanceCb
is set,regardless of whether an events channel is used.
Why: In this configuration, Poll()-based consumers did not receive the
rebalance event and could hang until a callback was wired. This change makes
Poll()-based apps receive
AssignedPartitions
/RevokedPartitions
so theycan call
Assign()
/Unassign()
to ack, aligning behavior with the config’sintent. No API changes; callback path unchanged.
Checklist
(Behavioral bug fix only; no API change; backward-compatible.)
(No new unit test in this PR; integration test typically requires a broker.
See “Test & Review” for manual steps. I can follow up with a tagged
integration test if desired.)
References
Fixes #1457
Test & Review
Local sanity:
go build ./...
✅go test ./...
✅ (unit tests; no broker required)Manual verification (requires reachable Kafka):
Create a consumer with:
"bootstrap.servers": "",
"group.id": "rebalance-poll-it",
"auto.offset.reset": "earliest",
"go.application.rebalance.enable": true
(No
RebalanceCb
; usePoll()
— no events channel.)Subscribe()
to a topic and callPoll()
in a loop.Before this change: no rebalance event arrives via
Poll()
.After this change: an
AssignedPartitions
/RevokedPartitions
event isreturned by
Poll()
.Call
Assign()
/Unassign()
accordingly; consumer proceeds and closes cleanly.Open questions / Follow-ups
handleRebalanceEvent
to explicitly document this behavior (refs Incorrect documentation on handleRebalanceEvent #1421).tag (requires
kafka/testconf.json
and a broker).