request.go 461 B

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