Skip to content

Commit

Permalink
Snappy encoding support
Browse files Browse the repository at this point in the history
Fixes #1
  • Loading branch information
Evan Huus committed Aug 8, 2013
1 parent e4ff187 commit 9885afe
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sarama

import (
"bytes"
"code.google.com/p/snappy-go/snappy"
"compress/gzip"
"io/ioutil"
)
Expand Down Expand Up @@ -52,7 +53,10 @@ func (m *Message) encode(pe packetEncoder) error {
body = buf.Bytes()
}
case COMPRESSION_SNAPPY:
// TODO
body, err = snappy.Encode(nil, m.Value)
if err != nil {
return err
}
}
err = pe.putBytes(body)
if err != nil {
Expand Down Expand Up @@ -108,7 +112,13 @@ func (m *Message) decode(pd packetDecoder) (err error) {
return err
}
case COMPRESSION_SNAPPY:
// TODO
if m.Value == nil {
return DecodingError
}
m.Value, err = snappy.Decode(nil, m.Value)
if err != nil {
return err
}
default:
return DecodingError
}
Expand Down

0 comments on commit 9885afe

Please sign in to comment.