package rpc2

Import Path
	github.com/cenkalti/rpc2 (on go.dev)

Dependency Relation
	imports 12 packages, and imported by one package

Involved Source Files Package rpc2 provides bi-directional RPC client and server similar to net/rpc. codec.go debug.go server.go state.go
Package-Level Type Names (total 8)
/* sort by: | */
Call represents an active RPC. // The argument to the function (*struct). // Strobes when call is complete. // After completion, the error status. // The name of the service and method to call. // The reply from the function (*struct). func (*Client).Go(method string, args interface{}, reply interface{}, done chan *Call) *Call func (*Client).Go(method string, args interface{}, reply interface{}, done chan *Call) *Call
Client represents an RPC Client. There may be multiple outstanding Calls associated with a single Client, and a Client may be used by multiple goroutines simultaneously. // additional information to associate with client Call invokes the named function, waits for it to complete, and returns its error status. CallWithContext invokes the named function, waits for it to complete, and returns its error status, or an error from Context timeout. Close waits for active calls to finish and closes the codec. DisconnectNotify returns a channel that is closed when the client connection has gone away. Go invokes the function asynchronously. It returns the Call structure representing the invocation. The done channel will signal when the call is complete by returning the same Call object. If done is nil, Go will allocate a new channel. If non-nil, done must be buffered or Go will deliberately crash. Handle registers the handler function for the given method. If a handler already exists for method, Handle panics. Notify sends a request to the receiver but does not wait for a return value. Run the client's read loop. You must run this method before calling any methods on the server. SetBlocking puts the client in blocking mode. In blocking mode, received requests are processes synchronously. If you have methods that may take a long time, other subsequent requests may time out. *Client : github.com/prometheus/common/expfmt.Closer *Client : github.com/robfig/cron/v3.Job *Client : io.Closer func NewClient(conn io.ReadWriteCloser) *Client func NewClientWithCodec(codec Codec) *Client func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Client).RemoteBye(_ *Client, _ *rpc.Empty, _ *rpc.Empty) error func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Client).RemotePushAllTicks(_ *Client, clocks []rpc.PushAllTicks, _ *rpc.Empty) error func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Client).RemoteSchemaChange(_ *Client, msg *rpc.RespHandshake, _ *rpc.Empty) error func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Client).RemoteSendingPayload(_ *Client, payload *rpc.ArgsPayload, _ *rpc.Empty) error func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Client).RemoteSendPayload(_ *Client, payload *rpc.ArgsPayload, _ *rpc.Empty) error func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Client).RemoteSetClock(_ *Client, clock *rpc.ClockMsg, _ *rpc.Empty) error func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Server).RemoteAdd(_ *Client, args *rpc.ArgsMut, resp *rpc.RespResult) error func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Server).RemoteAddNS(_ *Client, args *rpc.ArgsMut, _ *rpc.Empty) error func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Server).RemoteBye(_ *Client, _ *rpc.Empty, _ *rpc.Empty) error func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Server).RemoteHandshake(client *Client, id *string, _ *rpc.Empty) error func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Server).RemoteHello(client *Client, req *rpc.ArgsHello, resp *rpc.RespHandshake) error func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Server).RemoteRemove(_ *Client, args *rpc.ArgsMut, resp *rpc.RespResult) error func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Server).RemoteSet(_ *Client, args *rpc.ArgsMut, resp *rpc.RespResult) error func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Server).RemoteSetPushAllTicks(_ *Client, val bool, _ *rpc.Empty) error func github.com/pancsta/asyncmachine-go/pkg/rpc.(*Server).RemoteSync(_ *Client, sum uint64, resp *rpc.RespSync) error
A Codec implements reading and writing of RPC requests and responses. The client calls ReadHeader to read a message header. The implementation must populate either Request or Response argument. Depending on which argument is populated, ReadRequestBody or ReadResponseBody is called right after ReadHeader. ReadRequestBody and ReadResponseBody may be called with a nil argument to force the body to be read and then discarded. Close is called when client/server finished with the connection. ReadHeader must read a message and populate either the request or the response by inspecting the incoming message. ReadRequestBody into args argument of handler function. ReadResponseBody into reply argument of handler function. WriteRequest must be safe for concurrent use by multiple goroutines. WriteResponse must be safe for concurrent use by multiple goroutines. Codec : github.com/prometheus/common/expfmt.Closer Codec : io.Closer func NewGobCodec(conn io.ReadWriteCloser) Codec func NewClientWithCodec(codec Codec) *Client func (*Server).ServeCodec(codec Codec) func (*Server).ServeCodecWithState(codec Codec, state *State)
Request is a header written before every RPC call. Method string // sequence number chosen by client func Codec.ReadHeader(*Request, *Response) error func Codec.WriteRequest(*Request, interface{}) error
Response is a header written before every RPC return. // error, if any. // echoes that of the request func Codec.ReadHeader(*Request, *Response) error func Codec.WriteResponse(*Response, interface{}) error
Server responds to RPC requests made by Client. Accept accepts connections on the listener and serves requests for each incoming connection. Accept blocks; the caller typically invokes it in a go statement. Handle registers the handler function for the given method. If a handler already exists for method, Handle panics. OnConnect registers a function to run when a client connects. OnDisconnect registers a function to run when a client disconnects. ServeCodec is like ServeConn but uses the specified codec to decode requests and encode responses. ServeCodecWithState is like ServeCodec but also gives the ability to associate a state variable with the client that persists across RPC calls. ServeConn runs the server on a single connection. ServeConn blocks, serving the connection until the client hangs up. The caller typically invokes ServeConn in a go statement. ServeConn uses the gob wire format (see package gob) on the connection. To use an alternate codec, use ServeCodec. func NewServer() *Server
ServerError represents an error that has been returned from the remote side of the RPC connection. ( ServerError) Error() string ServerError : error
(*State) Get(key string) (value interface{}, ok bool) (*State) Set(key string, value interface{}) func NewState() *State func (*Server).ServeCodecWithState(codec Codec, state *State)
Package-Level Functions (total 5)
NewClient returns a new Client to handle requests to the set of services at the other end of the connection. It adds a buffer to the write side of the connection so the header and payload are sent as a unit.
NewClientWithCodec is like NewClient but uses the specified codec to encode requests and decode responses.
NewGobCodec returns a new rpc2.Codec using gob encoding/decoding on conn.
NewServer returns a new Server.
func NewState() *State
Package-Level Variables (total 2)
DebugLog controls the printing of internal and I/O errors.
ErrShutdown is returned when the connection is closing or closed.