Skip to content

Commit

Permalink
BalancePlan: add AsMemberIDMap
Browse files Browse the repository at this point in the history
The BalancePlan is opaque so as to reserve modification to its internal
structure. This modification is not likely, and having visibility into
the current plan may be beneficial.

We now add an API that returns the member => topic => partitions map,
and explicitly document that the underlying structure may change and
that the API will try to be as forward compatible as possible.
  • Loading branch information
twmb committed May 1, 2022
1 parent 04820f7 commit 8148c55
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/kgo/group_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,19 @@ type BalancePlan struct {
plan map[string]map[string][]int32 // member => topic => partitions
}

// AsMemberIDMap returns the plan as a map of member IDs to their topic &
// partition assignments.
//
// Internally, a BalancePlan is currently represented as this map. Any
// modification to the map modifies the plan. The internal representation of a
// plan may change in the future to include more metadata. If this happens, the
// map returned from this function may not represent all aspects of a plan.
// The client will attempt to mirror modifications to the map directly back
// into the underlying plan as best as possible.
func (p *BalancePlan) AsMemberIDMap() map[string]map[string][]int32 {
return p.plan
}

func (p *BalancePlan) String() string {
var sb strings.Builder

Expand Down

0 comments on commit 8148c55

Please sign in to comment.