cluster

package
v1.1.79 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2023 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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")
)
View Source
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 NewHandler

func NewHandler() *LocalHandler

NewHandler creates a new handler without node

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) Register

func (h *LocalHandler) Register(comp component.Component, opts []component.Option) error

Register register component on LocalHandler

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 NetAddr

type NetAddr struct {
	// contains filtered or unexported fields
}

func (*NetAddr) Network

func (n *NetAddr) Network() string

func (*NetAddr) String

func (n *NetAddr) String() string

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

CloseSession implements the MemberServer interface

func (*Node) CountSessions added in v1.0.1

func (n *Node) CountSessions() int

func (*Node) DelMember

DelMember is called by grpc `DelMember`

func (*Node) HandleNotify

HandleNotify is called by grpc `HandleNotify`

func (*Node) HandlePush

HandlePush is called by grpc `HandlePush`

func (*Node) HandleRequest

HandleRequest is called by grpc `HandleRequest`

func (*Node) HandleResponse

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

NewMember is called by grpc `NewMember`

func (*Node) SessionClosed

SessionClosed implements the MemberServer interface

func (*Node) SessionCreated added in v1.1.1

SessionCreated implements the MemberServer interface

func (*Node) Startup

func (n *Node) Startup(opt *options.Options) error

Startup bootstraps a start up.

func (*Node) WholeInterface added in v1.0.1

func (n *Node) WholeInterface(addr string) string

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 NewWSConn added in v1.0.1

func NewWSConn(conn *websocket.Conn) (*WSConn, error)

NewWSConn return an initialized *WSConn

func (*WSConn) Close added in v1.0.1

func (c *WSConn) Close() error

Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.

func (*WSConn) LocalAddr added in v1.0.1

func (c *WSConn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*WSConn) Read added in v1.0.1

func (c *WSConn) Read(b []byte) (int, error)

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

func (c *WSConn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

func (*WSConn) SetDeadline added in v1.0.1

func (c *WSConn) SetDeadline(t time.Time) error

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

func (c *WSConn) SetReadDeadline(t time.Time) error

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

func (c *WSConn) SetWriteDeadline(t time.Time) error

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.

func (*WSConn) Write added in v1.0.1

func (c *WSConn) Write(b []byte) (int, error)

Write writes data to the connection. Write can be made to time out and return an Error with Timeout() == true after a fixed time limit; see SetDeadline and SetWriteDeadline.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL