codec

package
v0.0.0-...-96640ab Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	MAX_SIZE_MB         = 4
	MAX_SIZE_BYTES      = MAX_SIZE_MB * 1024 * 1024
	DECODER_BUFFER_SIZE = 4 * 1024
)

Variables

View Source
var (
	// ErrSize is returned by Decode calls when a message would exceed the maximum allowed size.
	ErrSize = fmt.Errorf("proto: message exceeds %dMB", MAX_SIZE_MB)

	ProtobufCodec = &Codec{
		Name:               "protobuf",
		DecoderContentType: "application/x-protobuf",
		EncoderContentType: "application/x-protobuf",
		NewDecoder: func(r framing.Reader) *Decoder {
			return NewProtobufDecoder(r)
		},
		NewEncoder: func(w io.Writer) *Encoder {
			return NewProtobufEncoder(w)
		},
	}
)

Functions

This section is empty.

Types

type Codec

type Codec struct {
	Name               string
	DecoderContentType string
	EncoderContentType string
	NewEncoder         NewEncoderFunc
	NewDecoder         NewDecoderFunc
}

type Decoder

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

func NewJsonDecoder

func NewJsonDecoder(r framing.Reader) *Decoder

func NewProtobufDecoder

func NewProtobufDecoder(r framing.Reader) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode(m proto.Message) error

Decode reads the next message from its input and stores it in the value pointed to by m.

type Encoder

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

func NewJsonEncoder

func NewJsonEncoder(w io.Writer) *Encoder

func NewProtobufEncoder

func NewProtobufEncoder(w io.Writer) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(m proto.Message) error

type MarshalFunc

type MarshalFunc func(m proto.Message) ([]byte, error)

type NewDecoderFunc

type NewDecoderFunc func(r framing.Reader) *Decoder

type NewEncoderFunc

type NewEncoderFunc func(w io.Writer) *Encoder

type UnmarshalFunc

type UnmarshalFunc func(src []byte, m proto.Message) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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