Skip to content

Commit 8994085

Browse files
committed
broker: use user-configured max ApiVersions version if exists
Before, we always tried the latest client known version; we should obey the user max version if it is specified.
1 parent 957f943 commit 8994085

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: pkg/kgo/broker.go

+12
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,18 @@ func (cxn *brokerCxn) init() error {
467467

468468
func (cxn *brokerCxn) requestAPIVersions() error {
469469
maxVersion := int16(3)
470+
471+
// If the user configured a max versions, we check that the key exists
472+
// before entering this function. Thus, we expect exists to be true,
473+
// but we still doubly check it for sanity (as well as userMax, which
474+
// can only be non-negative based off of LookupMaxKeyVersion's API).
475+
if cxn.cl.cfg.maxVersions != nil {
476+
userMax, exists := cxn.cl.cfg.maxVersions.LookupMaxKeyVersion(18) // 18 == api versions
477+
if exists && userMax >= 0 {
478+
maxVersion = userMax
479+
}
480+
}
481+
470482
start:
471483
req := &kmsg.ApiVersionsRequest{
472484
Version: maxVersion,

0 commit comments

Comments
 (0)