codec

package
v0.0.0-...-6c569f3 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewCodecFuncMap map[Type]NewCodecFunc

Functions

This section is empty.

Types

type Codec

type Codec interface {
	io.Closer
	ReadHeader(*Header) error
	ReadBody(interface{}) error
	Write(*Header, interface{}) error
}

func NewGobCodec

func NewGobCodec(conn io.ReadWriteCloser) Codec

func NewJsonCodec

func NewJsonCodec(conn io.ReadWriteCloser) Codec

type GobCodec

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

func (*GobCodec) Close

func (g *GobCodec) Close() error

func (*GobCodec) ReadBody

func (g *GobCodec) ReadBody(body interface{}) error

func (*GobCodec) ReadHeader

func (g *GobCodec) ReadHeader(header *Header) error

func (*GobCodec) Write

func (g *GobCodec) Write(header *Header, body interface{}) (err error)
type Header struct {
	//ServiceMethod is formatted as "Service.Method"
	ServiceMethod string
	//Seq is the sequence number by client
	Seq   uint64
	Error string
}

type JsonCodec

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

func (*JsonCodec) Close

func (j *JsonCodec) Close() error

func (*JsonCodec) ReadBody

func (j *JsonCodec) ReadBody(body interface{}) error

func (*JsonCodec) ReadHeader

func (j *JsonCodec) ReadHeader(header *Header) error

func (*JsonCodec) Write

func (j *JsonCodec) Write(header *Header, body interface{}) (err error)

type NewCodecFunc

type NewCodecFunc func(io.ReadWriteCloser) Codec

type Type

type Type string
const (
	GobType  Type = "application/gob"
	JsonType Type = "application/json"
)

Jump to

Keyboard shortcuts

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