Documentation ¶
Overview ¶
Package zrpc is a generated protocol buffer package.
It is generated from these files:
request.proto response.proto
It has these top-level messages:
Request
Index ¶
- Constants
- Variables
- func CheckError(err error, statusCode int) bool
- func DefaultError(e zrpcError) string
- func NewBadRequestError(msg string) zrpcError
- func NewClientError(msg string, statusCode int) zrpcError
- func NewConflictError(msg string) zrpcError
- func NewError(msg string, statusCode int) zrpcError
- func NewExpiredError(msg string) zrpcError
- func NewForbiddenError(msg string) zrpcError
- func NewInternalError(msg string) zrpcError
- func NewNotFoundError(msg string) zrpcError
- func NewNotImplementedError(msg string) zrpcError
- func NewServiceNameContext(ctx context.Context, serviceName string) context.Context
- func ServiceNameFromContext(ctx context.Context) (string, bool)
- func StackTrace() (current, context string)
- func WrapError(err error, msg string, statusCode int) zrpcError
- type Call
- type Client
- type Request
- type Response
- type Response_Error
- type Server
Constants ¶
const ( RequestTimeout = time.Second * 2 RouterURL = "inproc://router" )
const (
EndpointReconnectInterval = time.Second * 5
)
Variables ¶
var ( ErrShutdown = errors.New("zrpc: connection is shut down") ErrMessageMismatch = errors.New("zrpc: received message ID did not match the one sent") ErrTimeout = errors.New("zrpc: request timeout") ErrCancel = errors.New("zrpc: request cancelled") ErrServiceNameMissing = errors.New("zrpc: missing service name (hint: pass it through the context)") )
Functions ¶
func CheckError ¶
CheckError checks if the given error is of the passed status code
func DefaultError ¶
func DefaultError(e zrpcError) string
A default implementation of the Error method of the error interface.
func NewBadRequestError ¶
func NewBadRequestError(msg string) zrpcError
func NewClientError ¶
NewClientError creates and returns a client error (without stack trace)
func NewConflictError ¶
func NewConflictError(msg string) zrpcError
func NewError ¶
This returns a new zrpcBaseError initialized with the given message and the current stack trace.
func NewExpiredError ¶
func NewExpiredError(msg string) zrpcError
func NewForbiddenError ¶
func NewForbiddenError(msg string) zrpcError
func NewInternalError ¶
func NewInternalError(msg string) zrpcError
func NewNotFoundError ¶
func NewNotFoundError(msg string) zrpcError
func NewNotImplementedError ¶
func NewNotImplementedError(msg string) zrpcError
func NewServiceNameContext ¶
NewServiceNameContext returns a new context carrying a service name
func ServiceNameFromContext ¶
ServiceNameFromContext extracts a servicename from passed context
func StackTrace ¶
func StackTrace() (current, context string)
This returns the current stack trace string. NOTE: the stack creation code is excluded from the stack trace.
Types ¶
type Call ¶
type Call struct { Service string // The service to send to Req proto.Message // The request to the function. Resp proto.Message // The reply from the function. // contains filtered or unexported fields }
Call represents an active call to a service.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used to interact with a service
func Dial ¶
Dial connects to a zrpc server at the specified network address Protocol is limited to tcp
func NewClient ¶
NewClient returns a new Client to handle requests to the service at the other end of the connection. A watcher is used to get updates about service endpoints
func NewClientWithConnection ¶
NewClientWithConnection returns a new Client to handle requests to the set of services at the other end of the connection. An existing connection in the form of a zmq socket together with the zmq context they were created with is used
type Request ¶
type Request struct { UUID []byte `protobuf:"bytes,1,opt" json:"UUID,omitempty"` Path *string `protobuf:"bytes,2,opt,name=path" json:"path,omitempty"` Payload []byte `protobuf:"bytes,3,opt,name=payload" json:"payload,omitempty"` Expires *int64 `protobuf:"varint,4,opt,name=expires" json:"expires,omitempty"` XXX_unrecognized []byte `json:"-"` }
Request is an envelope for sending a request from a client to a service
func (*Request) GetExpires ¶
func (*Request) GetPayload ¶
func (*Request) ProtoMessage ¶
func (*Request) ProtoMessage()
type Response ¶
type Response struct { UUID []byte `protobuf:"bytes,1,opt" json:"UUID,omitempty"` Path *string `protobuf:"bytes,2,opt,name=path" json:"path,omitempty"` Payload []byte `protobuf:"bytes,3,opt,name=payload" json:"payload,omitempty"` StatusCode *uint32 `protobuf:"varint,4,opt,name=status_code" json:"status_code,omitempty"` Error *Response_Error `protobuf:"bytes,5,opt,name=error" json:"error,omitempty"` XXX_unrecognized []byte `json:"-"` }
Response is an envelope for a service responding to a request from a client
func (*Response) GetError ¶
func (m *Response) GetError() *Response_Error
func (*Response) GetPayload ¶
func (*Response) GetStatusCode ¶
func (*Response) ProtoMessage ¶
func (*Response) ProtoMessage()
type Response_Error ¶
type Response_Error struct { Message *string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*Response_Error) GetMessage ¶
func (m *Response_Error) GetMessage() string
func (*Response_Error) ProtoMessage ¶
func (*Response_Error) ProtoMessage()
func (*Response_Error) Reset ¶
func (m *Response_Error) Reset()
func (*Response_Error) String ¶
func (m *Response_Error) String() string
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents an RPC Server.
func (*Server) Close ¶
func (server *Server) Close()
Close closes the server, usually deferred upon starting it
func (*Server) Register ¶
Register publishes in the server the set of methods of the receiver value that satisfy the following conditions:
- exported method
- two arguments, both of exported type
- the second argument is a pointer
- one return value, of type error
It returns an error if the receiver is not an exported type or has no suitable methods. It also logs the error using package log. The client accesses each method using a string of the form "Type.Method", where Type is the receiver's concrete type.
func (*Server) RegisterName ¶
RegisterName is like Register but uses the provided name for the type instead of the receiver's concrete type.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
reverseservice/reverseservicepb
Package reverseservicepb is a generated protocol buffer package.
|
Package reverseservicepb is a generated protocol buffer package. |