Documentation
¶
Index ¶
- Constants
- Variables
- func Accept(lis net.Listener)
- func HandleHTTP()
- func Register(rcvr interface{}) error
- type Args
- type Call
- type Client
- func Dial(network, address string, opts ...*Option) (client *Client, err error)
- func DialHttp(network, address string, opts ...*Option) (client *Client, err error)
- func NewClient(conn net.Conn, opt *Option) (*Client, error)
- func NewHTTPClient(conn net.Conn, opt *Option) (*Client, error)
- func XDial(rpcAddr string, opts ...*Option) (*Client, error)
- type Foo
- type Option
- type Server
Constants ¶
const MagicNumber = 0x3bef5c
Variables ¶
var DefaultOption = &Option{ MagicNumber: MagicNumber, CodecType: codec.GobType, ConnectionTimeoutSec: 10 * time.Second, HandleTimeoutSec: 0, }
var DefaultServer = NewServer()
DefaultServer is the default instance of *Server.
var ErrShutdown = errors.New("connection is shut down")
Functions ¶
func Accept ¶
Accept accepts connections on the listener and serves requests for each incoming connection.
func HandleHTTP ¶
func HandleHTTP()
HandleHTTP registers an HTTP handler for RPC messages on rpcPath, and a debugging handler on debugPath
Types ¶
type Call ¶
type Call struct { Seq uint64 // sequence number chosen by client ServiceMethod string // format "Service.Method" Args interface{} // arguments to the function Reply interface{} // reply from the function Error error // if error occurs, it will be set Done chan *Call // strobes when call is complete }
Call represents an active RPC.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
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.
func (*Client) Call ¶
func (client *Client) Call(ctx context.Context, serviceMethod string, args, reply interface{}) error
Call invokes the named function, waits for it to complete, and returns its error status.
func (*Client) Go ¶
Go invokes the function asynchronously. It returns the Call structure representing the invocation.
func (*Client) IsAvailable ¶
IsAvailable returns true if the client does work; in other words, it's not shutdown and not closing.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents an RPC Server.
func (*Server) Accept ¶
Accept accepts connections on the listener and serves requests for each incoming connection.
func (*Server) HandleHTTP ¶
func (server *Server) HandleHTTP()
func (*Server) Register ¶
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 or builtin type - the second argument is a pointer - one return value, of type error
func (*Server) ServerConn ¶
func (server *Server) ServerConn(conn io.ReadWriteCloser)
ServerConn runs the server on a single connection. ServerConn blocks, serving the connection until the client hangs up.