cluster

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2021 License: MIT Imports: 30 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")
	// ErrBufferExceeded indicates that the current session buffer is full and
	// can not receive more data.
	ErrBufferExceeded = errors.New("session send buffer exceed")
)
View Source
var (
	ErrSessionOnNotify     = errors.New("current session working on notify mode")
	ErrCloseClosedSession  = errors.New("close closed session")
	ErrInvalidRegisterReq  = errors.New("invalid register request")
	ErrInvalidRoute        = errors.New("invalid route")
	ErrMemberNotRegistered = errors.New("member is not registered")
	ErrRPC                 = errors.New("broken rpc")
)

Errors that could be occurred during message handling.

Functions

This section is empty.

Types

type CompInfo

type CompInfo struct {
	Name         string
	ReceiverType string
	HandlerType  string
	IsRawArg     bool
	Scheduler    string
}

CompInfo is the component information used by the node monitor

type LocalHandler

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

LocalHandler is the container for all local registered components

func NewHandler

func NewHandler(currentNode *Node, pipeline pipeline.Pipeline) *LocalHandler

NewHandler creates a LocalHandler

func (*LocalHandler) Components

func (h *LocalHandler) Components() []CompInfo

Components show a sorted list of local components for the node monitor

func (*LocalHandler) LocalService

func (h *LocalHandler) LocalService() []string

LocalService returns a sorted local service names

func (*LocalHandler) RemoteService

func (h *LocalHandler) RemoteService() []string

RemoteService returns a sorted remote service names

func (*LocalHandler) Remotes

func (h *LocalHandler) Remotes() []RemoteInfo

Remotes show a sorted remote components list for the node monitor

type Member

type Member struct {
	IsMaster bool
	*clusterpb.MemberInfo
}

Member is the remote component managed by cluster

type Node

type Node struct {
	Options            // current node options
	ServiceAddr string // current server service address
	// 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 (*Node) CloseSession

CloseSession implements the MemberServer interface

func (*Node) DelMember

DelMember implements the MemberServer interface

func (*Node) HandleNotify

HandleNotify implements the MemberServer interface

func (*Node) HandlePush

HandlePush implements the MemberServer interface

func (*Node) HandleRequest

HandleRequest implements the MemberServer interface

func (*Node) HandleResponse

HandleResponse implements the MemberServer interface

func (*Node) Handler

func (n *Node) Handler() *LocalHandler

Handler returns node's local handler

func (*Node) Members

func (n *Node) Members() []*Member

Members returns the cluster managed members

func (*Node) NewMember

NewMember implements the MemberServer interface

func (*Node) SessionClosed

SessionClosed implements the MemberServer interface

func (*Node) Sessions

func (n *Node) Sessions() []*session.Session

Sessions returns the node managed sessions

func (*Node) Shutdown

func (n *Node) Shutdown()

Shutdown all components registered by application, that call by reverse order against register

func (*Node) Startup

func (n *Node) Startup() error

Startup starts the node

func (*Node) Type

func (n *Node) Type() string

Type shows the node type: "Standalone" "Hub" "Gate" "Backend"

type Options

type Options struct {
	Pipeline         pipeline.Pipeline
	IsMaster         bool
	RegistryAddr     string
	RegisterInterval time.Duration
	GateAddr         string
	Components       *component.Components
	Label            string
	MonitorAddr      string

	WebsocketOptions
}

Options contains some configurations for current node

func NewOptions

func NewOptions() Options

NewOptions creates Options

type RemoteInfo

type RemoteInfo struct {
	Name string
	*clusterpb.MemberInfo
}

RemoteInfo is the remote component information used by the node monitor

type WebsocketOptions

type WebsocketOptions struct {
	IsWebsocket    bool
	TSLCertificate string
	TSLKey         string
	WSPath         string                   // WebSocket path (eg: ws://127.0.0.1/WSPath)
	ServeMux       *http.ServeMux           // do not rely on http.DefaultServeMux, use a private mux
	CheckOrigin    func(*http.Request) bool // check origin when websocket enabled
}

WebsocketOptions contains WebSocket related configurations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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