Skip to content

Commit

Permalink
broker: use user-configured max ApiVersions version if exists
Browse files Browse the repository at this point in the history
Before, we always tried the latest client known version; we should obey
the user max version if it is specified.
  • Loading branch information
twmb committed Feb 25, 2021
1 parent 957f943 commit 8994085
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/kgo/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,18 @@ func (cxn *brokerCxn) init() error {

func (cxn *brokerCxn) requestAPIVersions() error {
maxVersion := int16(3)

// If the user configured a max versions, we check that the key exists
// before entering this function. Thus, we expect exists to be true,
// but we still doubly check it for sanity (as well as userMax, which
// can only be non-negative based off of LookupMaxKeyVersion's API).
if cxn.cl.cfg.maxVersions != nil {
userMax, exists := cxn.cl.cfg.maxVersions.LookupMaxKeyVersion(18) // 18 == api versions
if exists && userMax >= 0 {
maxVersion = userMax
}
}

start:
req := &kmsg.ApiVersionsRequest{
Version: maxVersion,
Expand Down

0 comments on commit 8994085

Please sign in to comment.