request.go 514 B

1234567891011121314151617181920212223242526272829
  1. package kafka
  2. type requestBody interface {
  3. encoder
  4. key() int16
  5. version() int16
  6. expectResponse() bool
  7. topics() []topicRequest
  8. }
  9. type request struct {
  10. correlation_id int32
  11. id *string
  12. body requestBody
  13. }
  14. func (r *request) encode(pe packetEncoder) {
  15. pe.pushLength32()
  16. pe.putInt16(r.body.key())
  17. pe.putInt16(r.body.version())
  18. pe.putInt32(r.correlation_id)
  19. pe.putString(r.id)
  20. r.body.encode(pe)
  21. pe.pop()
  22. }
  23. func (r *request) expectResponse() bool {
  24. return r.body.expectResponse()
  25. }