Documentation
¶
Index ¶
- Constants
- Variables
- type Call
- type CallbackId
- type CallbackManager
- type Client
- func (client *Client) Call(serviceMethod string, args ...interface{}) error
- func (client *Client) Close() error
- func (client *Client) Go(done chan *Call, serviceMethod string, args ...interface{}) *Call
- func (client *Client) SubscribeToDisconnect(cb func(*Client)) error
- func (client *Client) SubscribeToPush(cb interface{}) error
- type Codec
- type Context
- func (me *Context) Done() <-chan struct{}
- func (me *Context) GetCancelFunc() context.CancelFunc
- func (me *Context) GetClientAddr() net.Addr
- func (me *Context) GetClientId() uint64
- func (me *Context) GetValue(key interface{}) interface{}
- func (me *Context) SetValue(key interface{}, value interface{})
- type ReCache
- type Registry
- func (registry *Registry) GetServiceMethod(serviceName string, methodName string) (service *serviceData, method *methodData)
- func (registry *Registry) Register(rcvr interface{}) error
- func (registry *Registry) RegisterType(val interface{})
- func (registry *Registry) RegisterWithName(rcvr interface{}, sname string) error
- type Request
- type Response
- type Server
- func (server *Server) Accept(lis net.Listener)
- func (server *Server) CodecFunc(c codecFunc)
- func (server *Server) ContextFunc(c contextFunc)
- func (server *Server) HandleHTTP()
- func (server *Server) ListenAndServe(addr string)
- func (server *Server) ListenAndServeTLS(addr string, certFile string, keyFile string)
- func (server *Server) ProcessConnection(conn net.Conn)
- func (server *Server) Register(endpoint interface{}) error
- func (server *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)
- type ServerError
Constants ¶
const ( R_RPC = iota //Normal RPC request R_PUSH //Push async data to client R_DATA //Send data to client )
const (
RPCPath = "/RPC"
)
Variables ¶
var ErrShutdown = errors.New("connection is shut down")
Functions ¶
This section is empty.
Types ¶
type CallbackId ¶
type CallbackId struct {
// contains filtered or unexported fields
}
type CallbackManager ¶
type CallbackManager struct {
// contains filtered or unexported fields
}
func (*CallbackManager) SendToAll ¶
func (cbmgr *CallbackManager) SendToAll(arg interface{})
Execute all subscribed functions to a push message
func (*CallbackManager) Subscribe ¶
func (cbmgr *CallbackManager) Subscribe(cb interface{}) (CallbackId, error)
Subscribe to pushed messages from the server
func (*CallbackManager) Unsubscribe ¶
func (cbmgr *CallbackManager) Unsubscribe(sid CallbackId)
Unsubscribe to pushed messages from the server
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func DialHTTP ¶
DialHTTP connects to an HTTP RPC server at the specified network address listening on the default HTTP RPC path.
func DialHTTPPath ¶
DialHTTPPath connects to an HTTP RPC server at the specified network address and path.
func NewClient ¶
func NewClient(conn io.ReadWriteCloser) *Client
It adds a buffer to the write side of the connection so the header and payload are sent as a unit.
func NewClientWithCodec ¶
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. 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.
func (*Client) SubscribeToDisconnect ¶
func (*Client) SubscribeToPush ¶
type Codec ¶
type Codec interface { Register(interface{}) WriteRequest(*Request, interface{}) error WriteResponse(*Response, interface{}) error ReadRequestHeader(*Request) error ReadResponseHeader(*Response) error ReadBody(interface{}) error Close() error }
func GenerateCodec ¶
func GenerateCodec(conn io.ReadWriteCloser) Codec
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func NewContext ¶
func NewContext() *Context
func (*Context) GetCancelFunc ¶
func (me *Context) GetCancelFunc() context.CancelFunc
Get a Cancellation function for this context
func (*Context) GetClientAddr ¶
Get client IP from context
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) GetServiceMethod ¶
func (*Registry) RegisterType ¶
func (registry *Registry) RegisterType(val interface{})
func (*Registry) RegisterWithName ¶
type Server ¶
type Server struct { ReCache // contains filtered or unexported fields }
func (*Server) Accept ¶
Accept accepts connections on the listener and serves requests for each incoming connection. Accept blocks; the caller typically invokes it in a go statement.
func (*Server) ContextFunc ¶
func (server *Server) ContextFunc(c contextFunc)
func (*Server) HandleHTTP ¶
func (server *Server) HandleHTTP()
This method will bind the different HTTP endpoints to their handlers
func (*Server) ListenAndServe ¶
func (*Server) ListenAndServeTLS ¶
func (*Server) ProcessConnection ¶
type ServerError ¶
type ServerError string
ServerError represents an error that has been returned from the remote side of the RPC connection.
func (ServerError) Error ¶
func (e ServerError) Error() string