|
|
@ -326,13 +326,13 @@ func (h *Handler) handleProduceV2Plus(correlationID uint32, apiVersion uint16, r |
|
|
if len(requestBody) < 2 { |
|
|
if len(requestBody) < 2 { |
|
|
return nil, fmt.Errorf("Produce v%d request too short for client_id", apiVersion) |
|
|
return nil, fmt.Errorf("Produce v%d request too short for client_id", apiVersion) |
|
|
} |
|
|
} |
|
|
clientIDLen := binary.BigEndian.Uint16(requestBody[offset:offset+2]) |
|
|
|
|
|
|
|
|
clientIDLen := binary.BigEndian.Uint16(requestBody[offset : offset+2]) |
|
|
offset += 2 |
|
|
offset += 2 |
|
|
|
|
|
|
|
|
if len(requestBody) < offset+int(clientIDLen) { |
|
|
if len(requestBody) < offset+int(clientIDLen) { |
|
|
return nil, fmt.Errorf("Produce v%d request client_id too short", apiVersion) |
|
|
return nil, fmt.Errorf("Produce v%d request client_id too short", apiVersion) |
|
|
} |
|
|
} |
|
|
clientID := string(requestBody[offset:offset+int(clientIDLen)]) |
|
|
|
|
|
|
|
|
clientID := string(requestBody[offset : offset+int(clientIDLen)]) |
|
|
offset += int(clientIDLen) |
|
|
offset += int(clientIDLen) |
|
|
fmt.Printf("DEBUG: Produce v%d - client_id: %s\n", apiVersion, clientID) |
|
|
fmt.Printf("DEBUG: Produce v%d - client_id: %s\n", apiVersion, clientID) |
|
|
|
|
|
|
|
|
@ -340,7 +340,7 @@ func (h *Handler) handleProduceV2Plus(correlationID uint32, apiVersion uint16, r |
|
|
if len(requestBody) < offset+2 { |
|
|
if len(requestBody) < offset+2 { |
|
|
return nil, fmt.Errorf("Produce v%d request too short for transactional_id", apiVersion) |
|
|
return nil, fmt.Errorf("Produce v%d request too short for transactional_id", apiVersion) |
|
|
} |
|
|
} |
|
|
transactionalIDLen := int16(binary.BigEndian.Uint16(requestBody[offset:offset+2])) |
|
|
|
|
|
|
|
|
transactionalIDLen := int16(binary.BigEndian.Uint16(requestBody[offset : offset+2])) |
|
|
offset += 2 |
|
|
offset += 2 |
|
|
|
|
|
|
|
|
var transactionalID string |
|
|
var transactionalID string |
|
|
@ -350,7 +350,7 @@ func (h *Handler) handleProduceV2Plus(correlationID uint32, apiVersion uint16, r |
|
|
if len(requestBody) < offset+int(transactionalIDLen) { |
|
|
if len(requestBody) < offset+int(transactionalIDLen) { |
|
|
return nil, fmt.Errorf("Produce v%d request transactional_id too short", apiVersion) |
|
|
return nil, fmt.Errorf("Produce v%d request transactional_id too short", apiVersion) |
|
|
} |
|
|
} |
|
|
transactionalID = string(requestBody[offset:offset+int(transactionalIDLen)]) |
|
|
|
|
|
|
|
|
transactionalID = string(requestBody[offset : offset+int(transactionalIDLen)]) |
|
|
offset += int(transactionalIDLen) |
|
|
offset += int(transactionalIDLen) |
|
|
} |
|
|
} |
|
|
fmt.Printf("DEBUG: Produce v%d - transactional_id: %s\n", apiVersion, transactionalID) |
|
|
fmt.Printf("DEBUG: Produce v%d - transactional_id: %s\n", apiVersion, transactionalID) |
|
|
@ -360,9 +360,9 @@ func (h *Handler) handleProduceV2Plus(correlationID uint32, apiVersion uint16, r |
|
|
return nil, fmt.Errorf("Produce v%d request missing acks/timeout", apiVersion) |
|
|
return nil, fmt.Errorf("Produce v%d request missing acks/timeout", apiVersion) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
acks := int16(binary.BigEndian.Uint16(requestBody[offset:offset+2])) |
|
|
|
|
|
|
|
|
acks := int16(binary.BigEndian.Uint16(requestBody[offset : offset+2])) |
|
|
offset += 2 |
|
|
offset += 2 |
|
|
timeout := binary.BigEndian.Uint32(requestBody[offset:offset+4]) |
|
|
|
|
|
|
|
|
timeout := binary.BigEndian.Uint32(requestBody[offset : offset+4]) |
|
|
offset += 4 |
|
|
offset += 4 |
|
|
|
|
|
|
|
|
fmt.Printf("DEBUG: Produce v%d - acks: %d, timeout: %d\n", apiVersion, acks, timeout) |
|
|
fmt.Printf("DEBUG: Produce v%d - acks: %d, timeout: %d\n", apiVersion, acks, timeout) |
|
|
@ -372,7 +372,7 @@ func (h *Handler) handleProduceV2Plus(correlationID uint32, apiVersion uint16, r |
|
|
return nil, fmt.Errorf("Produce v%d request missing topics count", apiVersion) |
|
|
return nil, fmt.Errorf("Produce v%d request missing topics count", apiVersion) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
topicsCount := binary.BigEndian.Uint32(requestBody[offset:offset+4]) |
|
|
|
|
|
|
|
|
topicsCount := binary.BigEndian.Uint32(requestBody[offset : offset+4]) |
|
|
offset += 4 |
|
|
offset += 4 |
|
|
|
|
|
|
|
|
fmt.Printf("DEBUG: Produce v%d - topics count: %d\n", apiVersion, topicsCount) |
|
|
fmt.Printf("DEBUG: Produce v%d - topics count: %d\n", apiVersion, topicsCount) |
|
|
@ -400,18 +400,18 @@ func (h *Handler) handleProduceV2Plus(correlationID uint32, apiVersion uint16, r |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
topicNameSize := binary.BigEndian.Uint16(requestBody[offset:offset+2]) |
|
|
|
|
|
|
|
|
topicNameSize := binary.BigEndian.Uint16(requestBody[offset : offset+2]) |
|
|
offset += 2 |
|
|
offset += 2 |
|
|
|
|
|
|
|
|
if len(requestBody) < offset+int(topicNameSize)+4 { |
|
|
if len(requestBody) < offset+int(topicNameSize)+4 { |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
topicName := string(requestBody[offset:offset+int(topicNameSize)]) |
|
|
|
|
|
|
|
|
topicName := string(requestBody[offset : offset+int(topicNameSize)]) |
|
|
offset += int(topicNameSize) |
|
|
offset += int(topicNameSize) |
|
|
|
|
|
|
|
|
// Parse partitions count
|
|
|
// Parse partitions count
|
|
|
partitionsCount := binary.BigEndian.Uint32(requestBody[offset:offset+4]) |
|
|
|
|
|
|
|
|
partitionsCount := binary.BigEndian.Uint32(requestBody[offset : offset+4]) |
|
|
offset += 4 |
|
|
offset += 4 |
|
|
|
|
|
|
|
|
fmt.Printf("DEBUG: Produce v%d - topic: %s, partitions: %d\n", apiVersion, topicName, partitionsCount) |
|
|
fmt.Printf("DEBUG: Produce v%d - topic: %s, partitions: %d\n", apiVersion, topicName, partitionsCount) |
|
|
@ -430,8 +430,8 @@ func (h *Handler) handleProduceV2Plus(correlationID uint32, apiVersion uint16, r |
|
|
// Skip partition parsing for now - just return success response
|
|
|
// Skip partition parsing for now - just return success response
|
|
|
|
|
|
|
|
|
// Response: partition_id(4) + error_code(2) + base_offset(8)
|
|
|
// Response: partition_id(4) + error_code(2) + base_offset(8)
|
|
|
response = append(response, 0, 0, 0, byte(j)) // partition_id
|
|
|
|
|
|
response = append(response, 0, 0) // error_code (success)
|
|
|
|
|
|
|
|
|
response = append(response, 0, 0, 0, byte(j)) // partition_id
|
|
|
|
|
|
response = append(response, 0, 0) // error_code (success)
|
|
|
response = append(response, 0, 0, 0, 0, 0, 0, 0, 0) // base_offset
|
|
|
response = append(response, 0, 0, 0, 0, 0, 0, 0, 0) // base_offset
|
|
|
|
|
|
|
|
|
// v2+ additional fields
|
|
|
// v2+ additional fields
|
|
|
|