瀏覽代碼

Merge pull request #147 from harpreet-sawhney/master

(cleanup) breaking out compressor from conn
Chris Bannister 11 年之前
父節點
當前提交
a331ecd561
共有 2 個文件被更改,包括 29 次插入24 次删除
  1. 29 0
      compressor.go
  2. 0 24
      conn.go

+ 29 - 0
compressor.go

@@ -0,0 +1,29 @@
+package gocql
+
+import (
+	"code.google.com/p/snappy-go/snappy"
+)
+
+
+type Compressor interface {
+	Name() string
+	Encode(data []byte) ([]byte, error)
+	Decode(data []byte) ([]byte, error)
+}
+
+// SnappyCompressor implements the Compressor interface and can be used to
+// compress incoming and outgoing frames. The snappy compression algorithm
+// aims for very high speeds and reasonable compression.
+type SnappyCompressor struct{}
+
+func (s SnappyCompressor) Name() string {
+	return "snappy"
+}
+
+func (s SnappyCompressor) Encode(data []byte) ([]byte, error) {
+	return snappy.Encode(nil, data)
+}
+
+func (s SnappyCompressor) Decode(data []byte) ([]byte, error) {
+	return snappy.Decode(nil, data)
+}

+ 0 - 24
conn.go

@@ -13,8 +13,6 @@ import (
 	"sync/atomic"
 	"time"
 	"unicode"
-
-	"code.google.com/p/snappy-go/snappy"
 )
 
 const defaultFrameSize = 4096
@@ -634,31 +632,9 @@ type callResp struct {
 	err error
 }
 
-type Compressor interface {
-	Name() string
-	Encode(data []byte) ([]byte, error)
-	Decode(data []byte) ([]byte, error)
-}
-
 type inflightPrepare struct {
 	info *queryInfo
 	err  error
 	wg   sync.WaitGroup
 }
 
-// SnappyCompressor implements the Compressor interface and can be used to
-// compress incoming and outgoing frames. The snappy compression algorithm
-// aims for very high speeds and reasonable compression.
-type SnappyCompressor struct{}
-
-func (s SnappyCompressor) Name() string {
-	return "snappy"
-}
-
-func (s SnappyCompressor) Encode(data []byte) ([]byte, error) {
-	return snappy.Encode(nil, data)
-}
-
-func (s SnappyCompressor) Decode(data []byte) ([]byte, error) {
-	return snappy.Decode(nil, data)
-}