encoding

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSpecifyThriftFile is returned if no Thrift file is specified
	// for a Thrift request.
	ErrSpecifyThriftFile = errors.New("specify a Thrift file using --thrift")
)

Functions

This section is empty.

Types

type Encoding

type Encoding string

Encoding is the representation of the data on the wire.

const (
	UnspecifiedEncoding Encoding = ""
	JSON                Encoding = "json"
	Thrift              Encoding = "thrift"
	Raw                 Encoding = "raw"
	Protobuf            Encoding = "proto"
)

The list of supported encodings.

func (Encoding) GetHealth

func (e Encoding) GetHealth(serviceName string) (Serializer, error)

GetHealth returns a serializer for the Health endpoint.

func (Encoding) String

func (e Encoding) String() string

func (*Encoding) UnmarshalFlag

func (e *Encoding) UnmarshalFlag(s string) error

UnmarshalFlag allows Encoding to be used as a flag.

func (*Encoding) UnmarshalText

func (e *Encoding) UnmarshalText(text []byte) error

UnmarshalText imlements the encoding.TextUnmarshaler interface used by JSON, YAML, etc.

type Serializer

type Serializer interface {
	// Encoding returns the encoding for this serializer.
	Encoding() Encoding

	// Request creates a transport.Request from the given []byte input.
	Request(body []byte) (*transport.Request, error)

	// Response converts a transport.Response into something that can be displayed to a user.
	// For non-raw encodings, this is typically a map[string]interface{}.
	Response(body *transport.Response) (response interface{}, err error)

	// CheckSuccess checks whether the response body is a success, and if not, returns an
	// error with the failure reason.
	CheckSuccess(body *transport.Response) error
}

Serializer serializes and deserializes data for a specific encoding and method.

func NewJSON

func NewJSON(methodName string) Serializer

NewJSON returns a JSON serializer.

func NewProtobuf added in v0.14.0

func NewProtobuf(fullMethodName string, source protobuf.DescriptorProvider) (Serializer, error)

NewProtobuf returns a protobuf serializer.

func NewRaw

func NewRaw(methodName string) Serializer

NewRaw returns a raw serializer.

func NewThrift

func NewThrift(thriftFile, methodName string, multiplexed bool) (Serializer, error)

NewThrift returns a Thrift serializer.

Jump to

Keyboard shortcuts

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