codec

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	// Marshal 编码
	Marshal(msgType message.Type, payload interface{}) ([]byte, error)
	// Unmarshal 解码
	Unmarshal(data []byte, registry *message.Registry) (msgType message.Type, payload interface{}, err error)
	// String 名称
	String() string
}

Codec 编解码器

type JSON

type JSON struct {
	// Type 类型
	Type message.Type `json:"type"`
	// Payload 消息体
	Payload json.RawMessage `json:"payload"`
}

JSON json格式

func (JSON) Marshal

func (JSON) Marshal(msgType message.Type, payload interface{}) ([]byte, error)

Marshal 编码

func (JSON) String

func (JSON) String() string

func (JSON) Unmarshal

func (JSON) Unmarshal(data []byte, registry *message.Registry) (msgType message.Type, payload interface{}, e error)

Unmarshal 解码

type Protobuf

type Protobuf struct{}

Protobuf protobuf格式

func (Protobuf) Marshal

func (Protobuf) Marshal(msgType message.Type, payload interface{}) ([]byte, error)

Marshal 编码

func (Protobuf) String

func (Protobuf) String() string

func (Protobuf) Unmarshal

func (Protobuf) Unmarshal(data []byte, registry *message.Registry) (msgType message.Type, payload interface{}, e error)

Unmarshal 解码

Jump to

Keyboard shortcuts

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