dispatcher

package
v2.0.0-alpha+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: Apache-2.0 Imports: 3 Imported by: 115

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher struct {
	// Protobuf should pass through to Google Protobuf in production paths
	Protobuf Protobuf
}

Dispatcher is used to handle the boilerplate proto tasks of unmarshaling inputs and remarshaling outputs so that the receiver may focus on the implementation details rather than the proto hassles.

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(inputBytes []byte, methodName string, receiver interface{}) ([]byte, error)

Dispatch deserializes the input bytes to the correct type for the method in the receiver, then if successful, marshals the output message to bytes and returns it. On error, it simply returns the error. The method on the receiver must take a single parameter which is a concrete proto message type and it should return a proto message and error.

type Protobuf

type Protobuf interface {
	Marshal(msg proto.Message) (marshaled []byte, err error)
	Unmarshal(marshaled []byte, msg proto.Message) error
}

Protobuf defines the subset of protobuf lifecycle needs and allows for injection of mocked marshaling errors.

type ProtobufImpl

type ProtobufImpl struct{}

ProtobufImpl is the standard implementation to use for Protobuf

func (ProtobufImpl) Marshal

func (p ProtobufImpl) Marshal(msg proto.Message) ([]byte, error)

Marshal passes through to proto.Marshal

func (ProtobufImpl) Unmarshal

func (p ProtobufImpl) Unmarshal(marshaled []byte, msg proto.Message) error

Unmarshal passes through to proto.Unmarshal

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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