Skip to content

Pr 193 #206

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

Merged
merged 2 commits into from
Apr 4, 2025
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
6 changes: 2 additions & 4 deletions proxy/processor_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ func (handler *DefaultRequestHandler) mustReply(requestKeyVersion *protocol.Requ
if err != nil {
return false, nil, err
}

case 3, 4, 5, 6, 7, 8, 9, 10, 11:
default:
// case 3, 4, 5, 6, 7, 8, 9, 10, 11, 12:
// CorrelationID + ClientID
if err = acksReader.ReadAndDiscardHeaderV1Part(reader); err != nil {
return false, nil, err
Expand All @@ -169,8 +169,6 @@ func (handler *DefaultRequestHandler) mustReply(requestKeyVersion *protocol.Requ
if err != nil {
return false, nil, err
}
default:
return false, nil, fmt.Errorf("produce version %d is not supported", requestKeyVersion.ApiVersion)
}
return acks != 0, bufferRead.Bytes(), nil
}
Expand Down
27 changes: 26 additions & 1 deletion proxy/protocol/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,32 @@ func createMetadataResponseSchemaVersions() []Schema {
&SchemaTaggedFields{Name: "response_tagged_fields"},
)

return []Schema{metadataResponseV0, metadataResponseV1, metadataResponseV2, metadataResponseV3, metadataResponseV4, metadataResponseV5, metadataResponseV6, metadataResponseV7, metadataResponseV8, metadataResponseV9, metadataResponseV10, metadataResponseV11, metadataResponseV12}
metadataResponseV13 := NewSchema("metadata_response_v13",
&Mfield{Name: "throttle_time_ms", Ty: TypeInt32},
&CompactArray{Name: brokersKeyName, Ty: metadataBrokerSchema9},
&Mfield{Name: "cluster_id", Ty: TypeCompactNullableStr},
&Mfield{Name: "controller_id", Ty: TypeInt32},
&CompactArray{Name: "topic_metadata", Ty: topicMetadataSchema12},
&Mfield{Name: "error_code", Ty: TypeInt16},
&SchemaTaggedFields{Name: "response_tagged_fields"},
)

return []Schema{
metadataResponseV0,
metadataResponseV1,
metadataResponseV2,
metadataResponseV3,
metadataResponseV4,
metadataResponseV5,
metadataResponseV6,
metadataResponseV7,
metadataResponseV8,
metadataResponseV9,
metadataResponseV10,
metadataResponseV11,
metadataResponseV12,
metadataResponseV13,
}
}

func createFindCoordinatorResponseSchemaVersions() []Schema {
Expand Down
120 changes: 120 additions & 0 deletions proxy/protocol/responses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ var (
return "myhost3", 34003, nil
} else if brokerHost == "localhost" && brokerPort == 9999 {
return "myhost", 34000, nil
} else if brokerHost == "localhost" && brokerPort == 9092 {
return "myhost5", 34005, nil
}
return "", 0, errors.New("unexpected data")
}
Expand Down Expand Up @@ -2436,6 +2438,124 @@ func TestMetadataResponseV11(t *testing.T) {
testMetadataResponse(t, apiVersion, payload, expectedInput, expectedModified)
}

func TestMetadataResponseV13(t *testing.T) {
apiVersion := int16(13)
payload := "0000000002000000010a6c6f63616c686f737400002384000017354c3667336e5368542d654d43744b2d2d58383673770000000102000010746573742d6e6f2d686561646572737d064a8944b14f078805ea02998647bf00040000000000010000000100000000020000000102000000010100000000000002000000010000000002000000010200000001010000000000000000000001000000000200000001020000000101008000000000000000"
expectedInput := []string{
"throttle_time_ms int32 0",
"[brokers]",
"brokers struct",
"node_id int32 1",
"host string localhost",
"port int32 9092",
"rack *string <nil>",
"[broker_tagged_fields]",
"cluster_id *string 5L6g3nShT-eMCtK--X86sw",
"controller_id int32 1",
"[topic_metadata]",
"topic_metadata struct",
"error_code int16 0",
"name *string test-no-headers",
"topic_id uuid 7d064a89-44b1-4f07-8805-ea02998647bf",
"is_internal bool false",
"[partition_metadata]",
"partition_metadata struct",
"error_code int16 0",
"partition int32 1",
"leader int32 1",
"leader_epoch int32 0",
"[replicas]",
"replicas int32 1",
"[isr]",
"isr int32 1",
"[offline_replicas]",
"[partition_metadata_tagged_fields]",
"partition_metadata struct",
"error_code int16 0",
"partition int32 2",
"leader int32 1",
"leader_epoch int32 0",
"[replicas]",
"replicas int32 1",
"[isr]",
"isr int32 1",
"[offline_replicas]",
"[partition_metadata_tagged_fields]",
"partition_metadata struct",
"error_code int16 0",
"partition int32 0",
"leader int32 1",
"leader_epoch int32 0",
"[replicas]",
"replicas int32 1",
"[isr]",
"isr int32 1",
"[offline_replicas]",
"[partition_metadata_tagged_fields]",
"topic_authorized_operations int32 -2147483648",
"[topic_metadata_tagged_fields]",
"error_code int16 0",
"[response_tagged_fields]",
}
expectedModified := []string{
"throttle_time_ms int32 0",
"[brokers]",
"brokers struct",
"node_id int32 1",
"host string myhost5",
"port int32 34005",
"rack *string <nil>",
"[broker_tagged_fields]",
"cluster_id *string 5L6g3nShT-eMCtK--X86sw",
"controller_id int32 1",
"[topic_metadata]",
"topic_metadata struct",
"error_code int16 0",
"name *string test-no-headers",
"topic_id uuid 7d064a89-44b1-4f07-8805-ea02998647bf",
"is_internal bool false",
"[partition_metadata]",
"partition_metadata struct",
"error_code int16 0",
"partition int32 1",
"leader int32 1",
"leader_epoch int32 0",
"[replicas]",
"replicas int32 1",
"[isr]",
"isr int32 1",
"[offline_replicas]",
"[partition_metadata_tagged_fields]",
"partition_metadata struct",
"error_code int16 0",
"partition int32 2",
"leader int32 1",
"leader_epoch int32 0",
"[replicas]",
"replicas int32 1",
"[isr]",
"isr int32 1",
"[offline_replicas]",
"[partition_metadata_tagged_fields]",
"partition_metadata struct",
"error_code int16 0",
"partition int32 0",
"leader int32 1",
"leader_epoch int32 0",
"[replicas]",
"replicas int32 1",
"[isr]",
"isr int32 1",
"[offline_replicas]",
"[partition_metadata_tagged_fields]",
"topic_authorized_operations int32 -2147483648",
"[topic_metadata_tagged_fields]",
"error_code int16 0",
"[response_tagged_fields]",
}
testMetadataResponse(t, apiVersion, payload, expectedInput, expectedModified)
}

func testMetadataResponse(t *testing.T, apiVersion int16, payload string, expectedInput, expectedModified []string) {
bytes, err := hex.DecodeString(payload)
if err != nil {
Expand Down