protorpc

package
v0.0.0-...-b5aa0b6 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package protorpc implements a protobuf-based ClientCodec and ServerCodec for the rpc package. Clients can make concurrent or asynchronous requests, and these are handled in whatever order the servers chooses.

All service methods take two protobuf message pointers: a request and a response. RPC service method strings, sequence numbers, and response errors are sent over the connection separately from the requests and responses.

Wire format: A request or response is encoded on the wire as a 32-bit length (in network byte order), followed by a marshalled protobuf for the header, followed by another 32-bit length, then a marshaled protobuf for the body. Separate length fields are used for framing because the protobuf encoding does not preserve message boundaries. Except for I/O errors, protobufs are encoded in pairs: first the header, then the request or response body.

Package protorpc is a generated protocol buffer package.

It is generated from these files:

protorpc.proto

It has these top-level messages:

ProtoRPCRequestHeader
ProtoRPCResponseHeader

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadRequestType  = errors.New("protorpc: bad request type")
	ErrMissingRequest  = errors.New("protorpc: missing request")
	ErrBadResponseType = errors.New("protorpc: bad response type")
	ErrMissingResponse = errors.New("protorpc: missing response")
)

Error types for the protorpc package.

Functions

func NewClient

func NewClient(conn io.ReadWriteCloser) *rpc.Client

NewClient returns a new rpc.Client to handle requests to the set of services at the other end of the connection.

func NewClientCodec

func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec

NewClientCodec returns a new rpc.ClientCodec using protobuf messages on conn.

func NewServerCodec

func NewServerCodec(conn io.ReadWriteCloser) rpc.ServerCodec

NewServerCodec returns a new rpc.ServerCodec using protobuf messages on conn.

Types

type ProtoRPCRequestHeader

type ProtoRPCRequestHeader struct {
	// The service method.
	Op *string `protobuf:"bytes,1,req,name=op" json:"op,omitempty"`
	// The sequence number.
	Seq              *uint64 `protobuf:"varint,2,req,name=seq" json:"seq,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

Protobuf RPC request header.

func (*ProtoRPCRequestHeader) GetOp

func (m *ProtoRPCRequestHeader) GetOp() string

func (*ProtoRPCRequestHeader) GetSeq

func (m *ProtoRPCRequestHeader) GetSeq() uint64

func (*ProtoRPCRequestHeader) ProtoMessage

func (*ProtoRPCRequestHeader) ProtoMessage()

func (*ProtoRPCRequestHeader) Reset

func (m *ProtoRPCRequestHeader) Reset()

func (*ProtoRPCRequestHeader) String

func (m *ProtoRPCRequestHeader) String() string

type ProtoRPCResponseHeader

type ProtoRPCResponseHeader struct {
	// The service method (matches request op).
	Op *string `protobuf:"bytes,1,req,name=op" json:"op,omitempty"`
	// The sequence number (matches request seq).
	Seq *uint64 `protobuf:"varint,2,req,name=seq" json:"seq,omitempty"`
	// The optional error string.
	Error            *string `protobuf:"bytes,3,opt,name=error" json:"error,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

Protobuf RPC response header.

func (*ProtoRPCResponseHeader) GetError

func (m *ProtoRPCResponseHeader) GetError() string

func (*ProtoRPCResponseHeader) GetOp

func (m *ProtoRPCResponseHeader) GetOp() string

func (*ProtoRPCResponseHeader) GetSeq

func (m *ProtoRPCResponseHeader) GetSeq() uint64

func (*ProtoRPCResponseHeader) ProtoMessage

func (*ProtoRPCResponseHeader) ProtoMessage()

func (*ProtoRPCResponseHeader) Reset

func (m *ProtoRPCResponseHeader) Reset()

func (*ProtoRPCResponseHeader) String

func (m *ProtoRPCResponseHeader) String() string

Jump to

Keyboard shortcuts

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