Documentation ¶
Overview ¶
Package urpc provides a minimal RPC package based on unet.
RPC requests are _not_ concurrent and methods must be explicitly registered. However, files may be send as part of the payload.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTooManyFiles = errors.New("too many files")
ErrTooManyFiles is returned when too many file descriptors are mapped.
var ErrUnknownMethod = errors.New("unknown method")
ErrUnknownMethod is returned when a method is not known.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Socket is the underlying socket for this client. // // This _must_ be provided and must be closed manually by calling // Close. Socket *unet.Socket // contains filtered or unexported fields }
Client is a urpc client.
type FilePayload ¶
FilePayload may be _embedded_ in another type in order to send or receive a file as a result of an RPC. These are not actually serialized, rather they are sent via an accompanying SCM_RIGHTS message (plumbed through the unet package).
When embedding a FilePayload in an argument struct, the argument type _must_ be a pointer to the struct rather than the struct type itself. This is because the urpc package defines pointer methods on FilePayload.
type RemoteError ¶
type RemoteError struct { // Message is the result of calling Error() on the remote error. Message string }
RemoteError is an error returned by the remote invocation.
This indicates that the RPC transport was correct, but that the called function itself returned an error.
func (RemoteError) Error ¶
func (r RemoteError) Error() string
Error returns the remote error string.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an RPC server.
func NewServerWithCallback ¶
func NewServerWithCallback(afterRPCCallback func()) *Server
NewServerWithCallback returns a new server, who upon completion of each RPC calls the given function.
func (*Server) Register ¶
Register registers the given object as an RPC receiver.
This functions is the same way as the built-in RPC package, but it does not tolerate any object with non-conforming methods. Any non-confirming methods will lead to an immediate panic, instead of being skipped or an error. Panics will also be generated by anonymous objects and duplicate entries.
func (*Server) StartHandling ¶
StartHandling creates a goroutine that handles a single client over a connection.
func (*Server) Stop ¶
Stop safely terminates outstanding clients.
No new requests should be initiated after calling Stop. Existing clients will be closed after completing any pending RPCs. This method will block until all clients have disconnected.
timeout is the time for clients to complete ongoing RPCs.