Documentation ¶
Index ¶
- Variables
- type LocalHandler
- func (h *LocalHandler) FindVersions(service string) []string
- func (h *LocalHandler) LocalDictionary() []*clusterpb.DictionaryItem
- func (h *LocalHandler) LocalService() []string
- func (h *LocalHandler) Register(comp component.Component, opts []component.Option) error
- func (h *LocalHandler) RemoteService() []string
- func (h *LocalHandler) RouteHandler(route string) (*component.Handler, error)
- type Member
- type NetAddr
- type Node
- func (n *Node) Close()
- func (n *Node) CloseSession(_ context.Context, req *clusterpb.CloseSessionRequest) (*clusterpb.CloseSessionResponse, error)
- func (n *Node) CountSessions() int
- func (n *Node) DelMember(_ context.Context, req *clusterpb.DelMemberRequest) (*clusterpb.DelMemberResponse, error)
- func (n *Node) HandleNotify(_ context.Context, req *clusterpb.NotifyMessage) (*clusterpb.MemberHandleResponse, error)
- func (n *Node) HandlePush(_ context.Context, req *clusterpb.PushMessage) (*clusterpb.MemberHandleResponse, error)
- func (n *Node) HandleRequest(_ context.Context, req *clusterpb.RequestMessage) (*clusterpb.MemberHandleResponse, error)
- func (n *Node) HandleResponse(_ context.Context, req *clusterpb.ResponseMessage) (*clusterpb.MemberHandleResponse, error)
- func (n *Node) Handler() *LocalHandler
- func (n *Node) ListenAndServeDebug()
- func (n *Node) NewMember(_ context.Context, req *clusterpb.NewMemberRequest) (*clusterpb.NewMemberResponse, error)
- func (n *Node) SessionClosed(_ context.Context, req *clusterpb.SessionClosedRequest) (*clusterpb.SessionClosedResponse, error)
- func (n *Node) SessionCreated(_ context.Context, req *clusterpb.SessionCreatedRequest) (*clusterpb.SessionCreatedResponse, error)
- func (n *Node) Startup(opt *options.Options) error
- func (n *Node) WholeInterface(addr string) string
- type WSConn
- func (c *WSConn) Close() error
- func (c *WSConn) LocalAddr() net.Addr
- func (c *WSConn) Read(b []byte) (int, error)
- func (c *WSConn) RemoteAddr() net.Addr
- func (c *WSConn) SetDeadline(t time.Time) error
- func (c *WSConn) SetReadDeadline(t time.Time) error
- func (c *WSConn) SetWriteDeadline(t time.Time) error
- func (c *WSConn) Write(b []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBrokenPipe represents the low-level connection has broken. ErrBrokenPipe = errors.New("broken low-level pipe") // ErrBufferExceed indicates that the current session buffer is full and // can not receive more data. ErrBufferExceed = errors.New("session send buffer exceed") )
var ( ErrCloseClosedSession = errors.New("close closed session") ErrInvalidRegisterReq = errors.New("invalid register request") )
Errors that could be occurred during message handling.
Functions ¶
This section is empty.
Types ¶
type LocalHandler ¶
type LocalHandler struct {
// contains filtered or unexported fields
}
LocalHandler stores local handlers & serivces info
func (*LocalHandler) FindVersions ¶
func (h *LocalHandler) FindVersions(service string) []string
FindVersions finds all versions for one service in cluster
func (*LocalHandler) LocalDictionary ¶
func (h *LocalHandler) LocalDictionary() []*clusterpb.DictionaryItem
LocalDictionary transforms local services info from map to slice
func (*LocalHandler) LocalService ¶
func (h *LocalHandler) LocalService() []string
LocalService transforms local services info from map to slice
func (*LocalHandler) RemoteService ¶
func (h *LocalHandler) RemoteService() []string
RemoteService transforms remote services info from map to slice
func (*LocalHandler) RouteHandler ¶
func (h *LocalHandler) RouteHandler(route string) (*component.Handler, error)
RouteHandler routes handler from localHandlers by route
type Member ¶
type Member struct {
// contains filtered or unexported fields
}
Member is a member of clusters
func (*Member) MemberInfo ¶
func (m *Member) MemberInfo() *clusterpb.MemberInfo
MemberInfo gets member info of a member
type Node ¶
type Node struct { *options.Options // current node options NodeID uint32 // current node ID // contains filtered or unexported fields }
Node represents a node in nano cluster, which will contains a group of services. All services will register to cluster and messages will be forwarded to the node which provides respective service
func DefaultNode ¶ added in v1.1.64
func DefaultNode() *Node
func (*Node) Close ¶ added in v1.1.14
func (n *Node) Close()
Close all components registered by application, that call by reverse order against register
func (*Node) CloseSession ¶
func (n *Node) CloseSession(_ context.Context, req *clusterpb.CloseSessionRequest) (*clusterpb.CloseSessionResponse, error)
CloseSession implements the MemberServer interface
func (*Node) CountSessions ¶ added in v1.0.1
func (*Node) DelMember ¶
func (n *Node) DelMember(_ context.Context, req *clusterpb.DelMemberRequest) (*clusterpb.DelMemberResponse, error)
DelMember is called by grpc `DelMember`
func (*Node) HandleNotify ¶
func (n *Node) HandleNotify(_ context.Context, req *clusterpb.NotifyMessage) (*clusterpb.MemberHandleResponse, error)
HandleNotify is called by grpc `HandleNotify`
func (*Node) HandlePush ¶
func (n *Node) HandlePush(_ context.Context, req *clusterpb.PushMessage) (*clusterpb.MemberHandleResponse, error)
HandlePush is called by grpc `HandlePush`
func (*Node) HandleRequest ¶
func (n *Node) HandleRequest(_ context.Context, req *clusterpb.RequestMessage) (*clusterpb.MemberHandleResponse, error)
HandleRequest is called by grpc `HandleRequest`
func (*Node) HandleResponse ¶
func (n *Node) HandleResponse(_ context.Context, req *clusterpb.ResponseMessage) (*clusterpb.MemberHandleResponse, error)
HandleResponse is called by grpc `HandleResponse`
func (*Node) Handler ¶
func (n *Node) Handler() *LocalHandler
Handler returns localhandler for this node.
func (*Node) ListenAndServeDebug ¶
func (n *Node) ListenAndServeDebug()
func (*Node) NewMember ¶
func (n *Node) NewMember(_ context.Context, req *clusterpb.NewMemberRequest) (*clusterpb.NewMemberResponse, error)
NewMember is called by grpc `NewMember`
func (*Node) SessionClosed ¶
func (n *Node) SessionClosed(_ context.Context, req *clusterpb.SessionClosedRequest) (*clusterpb.SessionClosedResponse, error)
SessionClosed implements the MemberServer interface
func (*Node) SessionCreated ¶ added in v1.1.1
func (n *Node) SessionCreated(_ context.Context, req *clusterpb.SessionCreatedRequest) (*clusterpb.SessionCreatedResponse, error)
SessionCreated implements the MemberServer interface
func (*Node) WholeInterface ¶ added in v1.0.1
type WSConn ¶ added in v1.0.1
type WSConn struct {
// contains filtered or unexported fields
}
WSConn is an adapter to t.Conn, which implements all t.Conn interface base on *websocket.Conn
func (*WSConn) Close ¶ added in v1.0.1
Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.
func (*WSConn) Read ¶ added in v1.0.1
Read reads data from the connection. Read can be made to time out and return an Error with Timeout() == true after a fixed time limit; see SetDeadline and SetReadDeadline.
func (*WSConn) RemoteAddr ¶ added in v1.0.1
RemoteAddr returns the remote network address.
func (*WSConn) SetDeadline ¶ added in v1.0.1
SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations fail with a timeout (see type Error) instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.
An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.
A zero value for t means I/O operations will not time out.
func (*WSConn) SetReadDeadline ¶ added in v1.0.1
SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.
func (*WSConn) SetWriteDeadline ¶ added in v1.0.1
SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.