codec

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2021 License: BSD-3-Clause Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ClientCodecVersion    = 1         // 协议版本
	ClientCodecHeaderSize = 14        // 消息头大小
	MaxAllowedV1SendBytes = 60 * 1024 // 最大发送消息大小(60k)
	MaxAllowedV1RecvBytes = 16 * 1024 // 最大接收消息大小(16k)
)
View Source
const (
	ZLIB  CompressType = 1
	FLATE CompressType = 2
	GZIP  CompressType = 3

	DefaultCompression = 0
	BestSpeed          = 1
	BestCompression    = 2
)
View Source
const (
	ServerCodecVersion      = 1               // 协议版本
	ServerCodecHeaderSize   = 24              // 消息头大小
	MaxAllowedV2PayloadSize = 8 * 1024 * 1024 // 最大包体大小(8M)
)

Variables

View Source
var ErrUnsupportedCodec = errors.New("unsupported codec type")

Functions

func CompressBytes

func CompressBytes(ctype CompressType, level int, data []byte) ([]byte, error)

func NewClientCodec added in v1.0.2

func NewClientCodec() *clientCodec

func NewServerCodec added in v1.0.2

func NewServerCodec() *serverCodec

func UnCompressBytes added in v1.0.2

func UnCompressBytes(ctype CompressType, data []byte) ([]byte, error)

Types

type CompressType added in v1.0.2

type CompressType int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL