protoutil

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Interceptor = func(_ proto.Message) {}

Interceptor will be called with every proto before it is marshalled. Interceptor is not safe to modify concurrently with calls to Marshal.

Functions

func Clone

func Clone(pb proto.Message) proto.Message

Clone uses proto.Clone to return a deep copy of pb. It panics if pb recursively contains any instances of types which are known to be unsupported by proto.Clone.

This function and its associated lint (see `make check`) exist to ensure we do not attempt to proto.Clone types which are not supported by proto.Clone. This hackery is necessary because proto.Clone gives no direct indication that it has incompletely cloned a type; it merely logs to standard output (see https://github.com/golang/protobuf/blob/89238a3/proto/clone.go#L204).

The concrete case against which this is currently guarding may be resolved upstream, see https://github.com/gogo/protobuf/issues/147.

func Marshal

func Marshal(pb proto.Message) ([]byte, error)

Marshal uses proto.Marshal to encode pb into the wire format. It is used in some tests to intercept calls to proto.Marshal.

Types

type JSONPb

type JSONPb jsonpb.Marshaler

JSONPb is a gwruntime.Marshaler that uses github.com/gogo/protobuf/jsonpb.

func (*JSONPb) ContentType

func (*JSONPb) ContentType() string

ContentType implements gwruntime.Marshaler.

func (*JSONPb) Marshal

func (j *JSONPb) Marshal(v interface{}) ([]byte, error)

Marshal implements gwruntime.Marshaler.

func (*JSONPb) NewDecoder

func (j *JSONPb) NewDecoder(r io.Reader) gwruntime.Decoder

NewDecoder implements gwruntime.Marshaler.

func (*JSONPb) NewEncoder

func (j *JSONPb) NewEncoder(w io.Writer) gwruntime.Encoder

NewEncoder implements gwruntime.Marshaler.

func (*JSONPb) Unmarshal

func (j *JSONPb) Unmarshal(data []byte, v interface{}) error

Unmarshal implements gwruntime.Marshaler.

type ProtoPb

type ProtoPb struct{}

ProtoPb is a gwruntime.Marshaler that uses github.com/gogo/protobuf/proto.

func (*ProtoPb) ContentType

func (*ProtoPb) ContentType() string

ContentType implements gwruntime.Marshaler.

func (*ProtoPb) Marshal

func (*ProtoPb) Marshal(v interface{}) ([]byte, error)

Marshal implements gwruntime.Marshaler.

func (*ProtoPb) NewDecoder

func (*ProtoPb) NewDecoder(r io.Reader) gwruntime.Decoder

NewDecoder implements gwruntime.Marshaler.

func (*ProtoPb) NewEncoder

func (*ProtoPb) NewEncoder(w io.Writer) gwruntime.Encoder

NewEncoder implements gwruntime.Marshaler.

func (*ProtoPb) Unmarshal

func (*ProtoPb) Unmarshal(data []byte, v interface{}) error

Unmarshal implements gwruntime.Marshaler.

Jump to

Keyboard shortcuts

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