codec

package
v0.0.0-...-d995e87 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteCodec

type ByteCodec struct{}

ByteCodec uses raw slice pf bytes and don't encode/decode.

func (ByteCodec) Decode

func (c ByteCodec) Decode(data []byte, i interface{}) error

Decode returns raw slice of bytes.

func (ByteCodec) Encode

func (c ByteCodec) Encode(i interface{}) ([]byte, error)

Encode returns raw slice of bytes.

type Codec

type Codec interface {
	Encode(i interface{}) ([]byte, error)
	Decode(data []byte, i interface{}) error
}

Codec defines the interface that decode/encode payload.

type JSONCodec

type JSONCodec struct{}

JSONCodec uses json marshaler and unmarshaler.

func (JSONCodec) Decode

func (c JSONCodec) Decode(data []byte, i interface{}) error

Decode decodes an object from slice of bytes.

func (JSONCodec) Encode

func (c JSONCodec) Encode(i interface{}) ([]byte, error)

Encode encodes an object into slice of bytes.

type MsgpackCodec

type MsgpackCodec struct {
	// contains filtered or unexported fields
}

MsgpackCodec uses messagepack marshaler and unmarshaler.

func NewMsgpackCodec

func NewMsgpackCodec(bufsize int) *MsgpackCodec

NewMsgpackCodec uses the optimised github.com/ugorji/go and we want to eliminate runtime allocations so a configurable buffer size can be set with the parameter and the codec can be reused

func (*MsgpackCodec) Decode

func (c *MsgpackCodec) Decode(data []byte, i interface{}) error

Decode decodes an object from slice of bytes.

func (*MsgpackCodec) Encode

func (c *MsgpackCodec) Encode(i interface{}) (out []byte, e error)

Encode encodes an object into slice of bytes.

type PBCodec

type PBCodec struct{}

PBCodec uses protobuf marshaler and unmarshaler.

func (PBCodec) Decode

func (c PBCodec) Decode(data []byte, i interface{}) error

Decode decodes an object from slice of bytes.

func (PBCodec) Encode

func (c PBCodec) Encode(i interface{}) ([]byte, error)

Encode encodes an object into slice of bytes.

type ThriftCodec

type ThriftCodec struct{}

func (ThriftCodec) Decode

func (c ThriftCodec) Decode(data []byte, i interface{}) error

func (ThriftCodec) Encode

func (c ThriftCodec) Encode(i interface{}) ([]byte, error)

Jump to

Keyboard shortcuts

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