Browse Source

fmt

pull/7231/head
chrislu 2 months ago
parent
commit
2a7d1ccacf
  1. 20
      weed/mq/kafka/protocol/produce.go

20
weed/mq/kafka/protocol/produce.go

@ -326,13 +326,13 @@ func (h *Handler) handleProduceV2Plus(correlationID uint32, apiVersion uint16, r
if len(requestBody) < 2 {
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
if len(requestBody) < offset+int(clientIDLen) {
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)
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 {
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
var transactionalID string
@ -350,7 +350,7 @@ func (h *Handler) handleProduceV2Plus(correlationID uint32, apiVersion uint16, r
if len(requestBody) < offset+int(transactionalIDLen) {
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)
}
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)
}
acks := int16(binary.BigEndian.Uint16(requestBody[offset:offset+2]))
acks := int16(binary.BigEndian.Uint16(requestBody[offset : offset+2]))
offset += 2
timeout := binary.BigEndian.Uint32(requestBody[offset:offset+4])
timeout := binary.BigEndian.Uint32(requestBody[offset : offset+4])
offset += 4
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)
}
topicsCount := binary.BigEndian.Uint32(requestBody[offset:offset+4])
topicsCount := binary.BigEndian.Uint32(requestBody[offset : offset+4])
offset += 4
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
}
topicNameSize := binary.BigEndian.Uint16(requestBody[offset:offset+2])
topicNameSize := binary.BigEndian.Uint16(requestBody[offset : offset+2])
offset += 2
if len(requestBody) < offset+int(topicNameSize)+4 {
break
}
topicName := string(requestBody[offset:offset+int(topicNameSize)])
topicName := string(requestBody[offset : offset+int(topicNameSize)])
offset += int(topicNameSize)
// Parse partitions count
partitionsCount := binary.BigEndian.Uint32(requestBody[offset:offset+4])
partitionsCount := binary.BigEndian.Uint32(requestBody[offset : offset+4])
offset += 4
fmt.Printf("DEBUG: Produce v%d - topic: %s, partitions: %d\n", apiVersion, topicName, partitionsCount)

Loading…
Cancel
Save