type Call(struct)
Call represents an active RPC.
// The argument to the function (*struct).
// Receives *Call when Go is complete.
// After completion, the error status.
// The reply from the function (*struct).
// The name of the service and method to call.
func (*Client).Go(serviceMethod string, args interface{}, reply interface{}, done chan *Call) *Call
func (*Client).Go(serviceMethod string, args interface{}, reply interface{}, done chan *Call) *Call
type Client(struct)
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.
Call invokes the named function, waits for it to complete, and returns its error status.
Close calls the underlying codec's Close method. If the connection is already
shutting down, ErrShutdown is returned.
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.
*T : io.Closer
func Dial(network, address string) (*Client, error)
func DialHTTP(network, address string) (*Client, error)
func DialHTTPPath(network, address, path string) (*Client, error)
func NewClient(conn io.ReadWriteCloser) *Client
func NewClientWithCodec(codec ClientCodec) *Client
func net/rpc/jsonrpc.Dial(network, address string) (*Client, error)
func net/rpc/jsonrpc.NewClient(conn io.ReadWriteCloser) *Client
type ClientCodec(interface)
A ClientCodec implements writing of RPC requests and
reading of RPC responses for the client side of an RPC session.
The client calls WriteRequest to write a request to the connection
and calls ReadResponseHeader and ReadResponseBody in pairs
to read responses. The client calls Close when finished with the
connection. ReadResponseBody may be called with a nil
argument to force the body of the response to be read and then
discarded.
See NewClient's comment for information about concurrent access.
( T) Close() error( T) ReadResponseBody(interface{}) error( T) ReadResponseHeader(*Response) error( T) WriteRequest(*Request, interface{}) error
T : io.Closer
func net/rpc/jsonrpc.NewClientCodec(conn io.ReadWriteCloser) ClientCodec
func NewClientWithCodec(codec ClientCodec) *Client
type Request(struct)
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.
// sequence number chosen by client
// format: "Service.Method"
func ClientCodec.WriteRequest(*Request, interface{}) error
func ServerCodec.ReadRequestHeader(*Request) error
type Response(struct)
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.
// error, if any.
// echoes that of the request
// echoes that of the Request
func ClientCodec.ReadResponseHeader(*Response) error
func ServerCodec.WriteResponse(*Response, interface{}) error
type Server(struct)
Server represents an RPC Server.
Accept accepts connections on the listener and serves requests
for each incoming connection. Accept blocks until the listener
returns a non-nil error. The caller typically invokes Accept in a
go statement.
HandleHTTP registers an HTTP handler for RPC messages on rpcPath,
and a debugging handler on debugPath.
It is still necessary to invoke http.Serve(), typically in a go statement.
Register publishes in the server the set of methods of the
receiver value that satisfy the following conditions:
- exported method of exported type
- 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.
RegisterName is like Register but uses the provided name for the type
instead of the receiver's concrete type.
ServeCodec is like ServeConn but uses the specified codec to
decode requests and encode responses.
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.
See NewClient's comment for information about concurrent access.
ServeHTTP implements an http.Handler that answers RPC requests.
ServeRequest is like ServeCodec but synchronously serves a single request.
It does not close the codec upon completion.
*T : net/http.Handler
func NewServer() *Server
var DefaultServer *Server
type ServerCodec(interface)
A ServerCodec implements reading of RPC requests and writing of
RPC responses for the server side of an RPC session.
The server calls ReadRequestHeader and ReadRequestBody in pairs
to read requests from the connection, and it calls WriteResponse to
write a response back. The server calls Close when finished with the
connection. ReadRequestBody may be called with a nil
argument to force the body of the request to be read and discarded.
See NewClient's comment for information about concurrent access.
Close can be called multiple times and must be idempotent.
( T) ReadRequestBody(interface{}) error( T) ReadRequestHeader(*Request) error( T) WriteResponse(*Response, interface{}) error
T : io.Closer
func net/rpc/jsonrpc.NewServerCodec(conn io.ReadWriteCloser) ServerCodec
func ServeCodec(codec ServerCodec)
func ServeRequest(codec ServerCodec) error
func (*Server).ServeCodec(codec ServerCodec)
func (*Server).ServeRequest(codec ServerCodec) error
type ServerErrorstring
ServerError represents an error that has been returned from
the remote side of the RPC connection.
( T) Error() string
T : error
Exported Values
func Accept(lis net.Listener)
Accept accepts connections on the listener and serves requests
to DefaultServer for each incoming connection.
Accept blocks; the caller typically invokes it in a go statement.
func Dial(network, address string) (*Client, error)
Dial connects to an RPC server at the specified network address.
func DialHTTP(network, address string) (*Client, error)
DialHTTP connects to an HTTP RPC server at the specified network address
listening on the default HTTP RPC path.
func DialHTTPPath(network, address, path string) (*Client, error)
DialHTTPPath connects to an HTTP RPC server
at the specified network address and path.
func HandleHTTP()
HandleHTTP registers an HTTP handler for RPC messages to DefaultServer
on DefaultRPCPath and a debugging handler on DefaultDebugPath.
It is still necessary to invoke http.Serve(), typically in a go statement.
func NewClient(conn io.ReadWriteCloser) *Client
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.
The read and write halves of the connection are serialized independently,
so no interlocking is required. However each half may be accessed
concurrently so the implementation of conn should protect against
concurrent reads or concurrent writes.
func NewClientWithCodec(codec ClientCodec) *Client
NewClientWithCodec is like NewClient but uses the specified
codec to encode requests and decode responses.
func Register(rcvr interface{}) error
Register publishes the receiver's methods in the DefaultServer.
func RegisterName(name string, rcvr interface{}) error
RegisterName is like Register but uses the provided name for the type
instead of the receiver's concrete type.
func ServeCodec(codec ServerCodec)
ServeCodec is like ServeConn but uses the specified codec to
decode requests and encode responses.
func ServeConn(conn io.ReadWriteCloser)
ServeConn runs the DefaultServer 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.
See NewClient's comment for information about concurrent access.
func ServeRequest(codec ServerCodec) error
ServeRequest is like ServeCodec but synchronously serves a single request.
It does not close the codec upon completion.
The pages are generated with Goldsv0.1.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project and developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.