Skip to content

Incorrect documentation on handleRebalanceEvent #1421

Open
@fgm

Description

@fgm

The end of the method comment appears to be wrong. It says:

// In the polling case (not channel based consumer) the rebalance event
// is returned in retval, else nil is returned.

While the code actually returns a non-nil event only in the channel case, which is the exact opposite of the comment.

  • lines 1022-1025: creates ev if there is a rebalanceCb or appRebalanceEnable
  • lines 1029-1034 : returns it if channel != nil && c.appRebalanceEnable && c.rebalanceCb == nil which is the opposite of the documentation
  • line 1046: return nil if there is a rebalanceCb and it called Assign/Unassign
  • line 1088: return nil unconditionally

It seems that:

  • either the doc should read like this instead:

     // In the polling case (not channel based consumer) the rebalance event
     // is passed to the `rebalanceCb` if it is set, and never returned to `eventPoll`
    
  • or the function logic should be amended to match the comment and allow the method to return the event to eventPoll.

The latter would provide most consistent handling, but would make it easier for callers to introduce bugs in their code because then the protection logic built when calling rebalanceCb would have no equivalent for the processing in eventPoll.

Do you want a PR either way ?

(tangentially related to #624 / #625)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions