Prechádzať zdrojové kódy

Revert "Compression codec is high three bits, not low"

This reverts commit 7d6070c06e60461d73f49f4e30a3bd580d525b4e.
Evan Huus 12 rokov pred
rodič
commit
901b907636
2 zmenil súbory, kde vykonal 5 pridanie a 5 odobranie
  1. 3 3
      message.go
  2. 2 2
      message_test.go

+ 3 - 3
message.go

@@ -8,7 +8,7 @@ import (
 )
 
 // CompressionCodec represents the various compression codecs recognized by Kafka in messages.
-type CompressionCodec uint8
+type CompressionCodec int8
 
 const (
 	CompressionNone   CompressionCodec = 0
@@ -33,7 +33,7 @@ func (m *Message) encode(pe packetEncoder) error {
 
 	pe.putInt8(messageFormat)
 
-	attributes := int8(m.Codec << 5)
+	attributes := int8(m.Codec) & 0x07
 	pe.putInt8(attributes)
 
 	err := pe.putBytes(m.Key)
@@ -95,7 +95,7 @@ func (m *Message) decode(pd packetDecoder) (err error) {
 	if err != nil {
 		return err
 	}
-	m.Codec = CompressionCodec(attribute >> 5)
+	m.Codec = CompressionCodec(attribute & 0x07)
 
 	m.Key, err = pd.getBytes()
 	if err != nil {

+ 2 - 2
message_test.go

@@ -11,9 +11,9 @@ var (
 		0xFF, 0xFF, 0xFF, 0xFF} // value
 
 	emptyGzipMessage = []byte{
-		0xAA, 0x27, 0x4D, 0x22, //CRC
+		97, 79, 149, 90, //CRC
 		0x00,                   // magic version byte
-		0x20,                   // attribute flags
+		0x01,                   // attribute flags
 		0xFF, 0xFF, 0xFF, 0xFF, // key
 		// value
 		0x00, 0x00, 0x00, 0x17,