12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package sarama
- type ControlRecordType int
- const (
- ControlRecordAbort ControlRecordType = iota
- ControlRecordCommit
- ControlRecordUnknown
- )
- type ControlRecord struct {
- Version int16
- CoordinatorEpoch int32
- Type ControlRecordType
- }
- func (cr *ControlRecord) decode(key, value packetDecoder) error {
- {
- var err error
- cr.Version, err = value.getInt16()
- if err != nil {
- return err
- }
- cr.CoordinatorEpoch, err = value.getInt32()
- if err != nil {
- return err
- }
- }
- {
- var err error
-
-
- cr.Version, err = key.getInt16()
- if err != nil {
- return err
- }
- recordType, err := key.getInt16()
- if err != nil {
- return err
- }
- switch recordType {
- case 0:
- cr.Type = ControlRecordAbort
- case 1:
- cr.Type = ControlRecordCommit
- default:
-
-
- cr.Type = ControlRecordUnknown
- }
- }
- return nil
- }
- func (cr *ControlRecord) encode(key, value packetEncoder) {
- value.putInt16(cr.Version)
- value.putInt32(cr.CoordinatorEpoch)
- key.putInt16(cr.Version)
- switch cr.Type {
- case ControlRecordAbort:
- key.putInt16(0)
- case ControlRecordCommit:
- key.putInt16(1)
- }
- }
|