rpcd

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RpcdSourceGrowerGateway = "grower-gateway"
)

Variables

View Source
var ErrShutdown = errors.New("connection is shut down")

Functions

func NewPbClientCodec

func NewPbClientCodec(conn io.ReadWriteCloser) *pbClientCodec

func NewPbServerCode

func NewPbServerCode(conn io.ReadWriteCloser) *pbServerCodec

Types

type Call

type Call struct {
	ServiceMethod string      // The name of the service and method to call.
	Args          interface{} // The argument to the function (*struct).
	Reply         interface{} // The reply from the function (*struct).
	Error         error       // After completion, the error status.
	Done          chan *Call  // Receives *Call when Go is complete.
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func Dial

func Dial(network, address string, opts ...DialOption) (*Client, error)

func NewClientWithCodec

func NewClientWithCodec(codec ClientCodec) *Client

func (*Client) Call

func (client *Client) Call(serviceMethod string, args interface{}, reply interface{}) error

Call invokes the named function, waits for it to complete, and returns its error status.

func (*Client) Close

func (client *Client) Close() error

func (*Client) ClosedOrShutdowned

func (client *Client) ClosedOrShutdowned() bool

func (*Client) Go

func (client *Client) Go(serviceMethod string, args interface{}, reply interface{}, done chan *Call) *Call

type ClientCodec

type ClientCodec interface {
	WriteRequest(*Request, interface{}) error
	ReadResponseHeader(*Response) error
	ReadResponseBody(interface{}) error

	Close() error
}

type DialOption

type DialOption interface {
	// contains filtered or unexported methods
}

func WithTimeout

func WithTimeout(seconds time.Duration) DialOption

type RPCServer

type RPCServer struct {
	// contains filtered or unexported fields
}

func NewRPCServer

func NewRPCServer() *RPCServer

func (*RPCServer) RegisterName

func (server *RPCServer) RegisterName(name string, rcvr interface{}, routes map[string]string) error

RegisterName is like Register but uses the provided name for the type instead of the receiver's concrete type.

func (*RPCServer) ServeCodec

func (server *RPCServer) ServeCodec(codec ServerCodec)

ServeCodec is like ServeConn but uses the specified codec to decode requests and encode responses.

func (*RPCServer) ServeRequest

func (server *RPCServer) ServeRequest(codec ServerCodec) error

ServeRequest is like ServeCodec but synchronously serves a single request. It does not close the codec upon completion.

func (*RPCServer) ServeWithPbCodec

func (rs *RPCServer) ServeWithPbCodec(addr string) error

type Request

type Request struct {
	ServiceMethod string // format: "Service.Method"
	Seq           uint64 // sequence number chosen by client
	// contains filtered or unexported fields
}

Request is a header written before every RPC call. It is used internally but documented here as an aid to debugging, such as when analyzing network traffic.

type RequestHeader

type RequestHeader struct {
	Id         uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"`
	Method     string `protobuf:"bytes,2,opt,name=method" json:"method,omitempty"`
	RpcdSource string `protobuf:"bytes,3,opt,name=rpcdSource" json:"rpcdSource,omitempty"`
	Checksum   uint32 `protobuf:"varint,5,opt,name=checksum" json:"checksum,omitempty"`
}

func (*RequestHeader) Check

func (m *RequestHeader) Check(body []byte) error

func (*RequestHeader) ProtoMessage

func (*RequestHeader) ProtoMessage()

func (*RequestHeader) Reset

func (m *RequestHeader) Reset()

func (*RequestHeader) String

func (m *RequestHeader) String() string

type Response

type Response struct {
	ServiceMethod string // echoes that of the Request
	Seq           uint64 // echoes that of the request
	Error         string // error, if any.
	// contains filtered or unexported fields
}

Response is a header written before every RPC return. It is used internally but documented here as an aid to debugging, such as when analyzing network traffic.

type ResponseHeader

type ResponseHeader struct {
	Id       uint64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"`
	Error    string `protobuf:"bytes,2,opt,name=error" json:"error,omitempty"`
	Method   string `protobuf:"bytes,2,opt,name=method" json:"method,omitempty"`
	Checksum uint32 `protobuf:"varint,5,opt,name=checksum" json:"checksum,omitempty"`
}

func (*ResponseHeader) Check

func (m *ResponseHeader) Check(body []byte) error

func (*ResponseHeader) ProtoMessage

func (*ResponseHeader) ProtoMessage()

func (*ResponseHeader) Reset

func (m *ResponseHeader) Reset()

func (*ResponseHeader) String

func (m *ResponseHeader) String() string

type ServerCodec

type ServerCodec interface {
	ReadRequestHeader(*Request) error
	ReadRequestBody(interface{}) error
	WriteResponse(*Response, interface{}) error

	// Close can be called multiple times and must be idempotent.
	Close() error
}

type ServerError

type ServerError string

ServerError represents an error that has been returned from the remote side of the RPC connection.

func (ServerError) Error

func (e ServerError) Error() string

type SugarCoatingRequest

type SugarCoatingRequest struct {
	RpcdSource string `protobuf:"bytes,1,opt,name=RpcdSource" json:"RpcdSource,omitempty"`
	Data       []byte `protobuf:"bytes,2,opt,name=data" json:"data,omitempty"`
}

func GenSugarCoatingRequest

func GenSugarCoatingRequest(source string, data []byte) *SugarCoatingRequest

func (*SugarCoatingRequest) ProtoMessage

func (*SugarCoatingRequest) ProtoMessage()

func (*SugarCoatingRequest) Reset

func (m *SugarCoatingRequest) Reset()

func (*SugarCoatingRequest) String

func (m *SugarCoatingRequest) String() string

type SugarCoatingResponse

type SugarCoatingResponse struct {
	Data []byte `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
}

func (*SugarCoatingResponse) GetSugarData

func (m *SugarCoatingResponse) GetSugarData() ([]byte, error)

func (*SugarCoatingResponse) ProtoMessage

func (*SugarCoatingResponse) ProtoMessage()

func (*SugarCoatingResponse) Reset

func (m *SugarCoatingResponse) Reset()

func (*SugarCoatingResponse) String

func (m *SugarCoatingResponse) String() string

type SugarCoatingResponseInterface

type SugarCoatingResponseInterface interface {
	GetSugarData() ([]byte, error)
}

Jump to

Keyboard shortcuts

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