mirror of
https://github.com/smallnest/rpcx.git
synced 2025-10-07 09:01:01 +08:00
35 lines
663 B
Go
35 lines
663 B
Go
package protocol
|
|
|
|
import (
|
|
"github.com/smallnest/rpcx/util"
|
|
)
|
|
|
|
// Compressor defines a common compression interface.
|
|
type Compressor interface {
|
|
Zip([]byte) ([]byte, error)
|
|
Unzip([]byte) ([]byte, error)
|
|
}
|
|
|
|
// GzipCompressor implements gzip compressor.
|
|
type GzipCompressor struct {
|
|
}
|
|
|
|
func (c GzipCompressor) Zip(data []byte) ([]byte, error) {
|
|
return util.Zip(data)
|
|
}
|
|
|
|
func (c GzipCompressor) Unzip(data []byte) ([]byte, error) {
|
|
return util.Unzip(data)
|
|
}
|
|
|
|
type RawDataCompressor struct {
|
|
}
|
|
|
|
func (c RawDataCompressor) Zip(data []byte) ([]byte, error) {
|
|
return data, nil
|
|
}
|
|
|
|
func (c RawDataCompressor) Unzip(data []byte) ([]byte, error) {
|
|
return data, nil
|
|
}
|