Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(producer): use newer ProduceReq as appropriate #2546

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion async_producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ func TestTxnProduceBumpEpoch(t *testing.T) {
broker.Returns(addPartitionsToTxnResponse)

produceResponse := new(ProduceResponse)
produceResponse.Version = 3
produceResponse.Version = 7
produceResponse.AddTopicPartition("test-topic", 0, ErrOutOfOrderSequenceNumber)
broker.Returns(produceResponse)

Expand Down
20 changes: 13 additions & 7 deletions produce_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,22 @@ func (r *ProduceRequest) isValidVersion() bool {

func (r *ProduceRequest) requiredVersion() KafkaVersion {
switch r.Version {
case 1:
return V0_9_0_0
case 2:
return V0_10_0_0
case 3:
return V0_11_0_0
case 7:
return V2_1_0_0
case 6:
return V2_0_0_0
case 4, 5:
return V1_0_0_0
case 3:
return V0_11_0_0
case 2:
return V0_10_0_0
case 1:
return V0_9_0_0
case 0:
return V0_8_2_0
default:
return MinVersion
return V2_1_0_0
}
}

Expand Down
19 changes: 18 additions & 1 deletion produce_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,24 @@ func (r *ProduceResponse) isValidVersion() bool {
}

func (r *ProduceResponse) requiredVersion() KafkaVersion {
return MinVersion
switch r.Version {
case 7:
return V2_1_0_0
case 6:
return V2_0_0_0
case 4, 5:
return V1_0_0_0
case 3:
return V0_11_0_0
case 2:
return V0_10_0_0
case 1:
return V0_9_0_0
case 0:
return V0_8_2_0
default:
return V2_1_0_0
}
}

func (r *ProduceResponse) throttleTime() time.Duration {
Expand Down
9 changes: 7 additions & 2 deletions produce_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,13 @@ func (ps *produceSet) buildRequest() *ProduceRequest {
req.TransactionalID = &ps.parent.conf.Producer.Transaction.ID
}
}

if ps.parent.conf.Producer.Compression == CompressionZSTD && ps.parent.conf.Version.IsAtLeast(V2_1_0_0) {
if ps.parent.conf.Version.IsAtLeast(V1_0_0_0) {
req.Version = 5
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slightly pedantic but these could be else cases.

if ps.parent.conf.Version.IsAtLeast(V2_0_0_0) {
req.Version = 6
}
if ps.parent.conf.Version.IsAtLeast(V2_1_0_0) {
req.Version = 7
}

Expand Down
Loading