grpccodec

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 3 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 {
	// DecodeRequest converts a proto message to a Go value.
	// It is designed to be used at the server side.
	DecodeRequest(pb proto.Message, out interface{}) error

	// EncodeResponse converts a Go value to a proto message.
	// It is designed to be used at the server side.
	EncodeResponse(in interface{}, pb proto.Message) error
}

Codec is a series of codecs (encoders and decoders) for gRPC requests and responses.

type Codecs

type Codecs interface {
	EncodeDecoder(name string) Codec
}

type DefaultCodecs

type DefaultCodecs struct {
	Codecs map[string]Codec
	// contains filtered or unexported fields
}

func NewDefaultCodecs

func NewDefaultCodecs(d Codec, namedCodecs ...NamedCodec) *DefaultCodecs

func (*DefaultCodecs) EncodeDecoder

func (dc *DefaultCodecs) EncodeDecoder(name string) Codec

type NamedCodec

type NamedCodec struct {
	Name  string
	Codec Codec
}

NamedCodec holds a codec and its corresponding operation name.

func Op

func Op(name string, codec Codec) NamedCodec

Op is a shortcut for creating an instance of NamedCodec.

type ProtoJSON

type ProtoJSON struct{}

func (ProtoJSON) DecodeRequest

func (pj ProtoJSON) DecodeRequest(pb proto.Message, out interface{}) error

func (ProtoJSON) EncodeResponse

func (pj ProtoJSON) EncodeResponse(in interface{}, pb proto.Message) error

Jump to

Keyboard shortcuts

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