Documentation
¶
Index ¶
Constants ¶
const (
MagicNumber = 0x123abc
)
Variables ¶
var DefaultOption = &Option{ MagicNumber: MagicNumber, CodecType: codec.TypeGob, ConnectTimeout: time.Second * 10, }
var DefaultServer = NewServer()
var ErrShutdown = errors.New("connection is shut down")
Functions ¶
Types ¶
type Call ¶
type Call struct {
Seq uint64
ServiceMethod string // format "<service>.<method>"
Args interface{} // arguments to the function
Resp interface{} // resp 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 ¶
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 return true if the client does work
type Option ¶
type Option struct {
MagicNumber int
CodecType codec.Type
ConnectTimeout time.Duration // 0 means no limit
HandleTimeout time.Duration
}
Option this filed is the start in conn msg [<- Option ->][<- Header ->][<- Body ->][<- Header ->][<- Body ->]...... part of [<- Option ->] is codec by json part of [<- Header ->] and [<- Body ->] is codec by Option.CodecType
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents an RPC Server.
func (*Server) ServeConn ¶
func (server *Server) ServeConn(conn io.ReadWriteCloser)
ServeConn handle the incoming conn