cluster

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LockKey    = "/NodeLaunchMutex" // 节点启动锁
	NodePrefix = "/AllNode/"        // 节点前缀
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

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

func NewCluster

func NewCluster(ctx context.Context, logger *logutil.Logger, nodeID uint16) *Cluster

NewCluster Launch a not exist node in cluster.

func (*Cluster) BordcastMsg

func (c *Cluster) BordcastMsg(data *protocol.SSMessage)

BordcastMsg Send message to all of node.

func (*Cluster) Close

func (c *Cluster) Close()

Close Shutdown the communicator and close all of already exist sessions.

func (*Cluster) Init

Init Launch a not exist node in cluster. Initalization cluster node, include listen port, registry and connect, if either operation fails, will panic.

func (*Cluster) OnConnect

func (c *Cluster) OnConnect(sessionID uint64, addr string)

OnConnect Recive a new connect form listener/dialer If underlying support it, then convert it to NodeRemote and cache it

func (*Cluster) OnDisconnect

func (c *Cluster) OnDisconnect(sessionID uint64, err error)

OnDisconnect The session disconnected, the remote device initiates or actively disconnects

func (*Cluster) OnMessage

func (c *Cluster) OnMessage(sessionID uint64, msg *protocol.SSMessage)

OnMessage Recive a new message. Just recive the message from session. And push it to InPipe.

func (*Cluster) Pack

func (c *Cluster) Pack(payload *protocol.SSMessage, buf *bytes.Buffer)

Pack Encode messages that are communicated between cluster nodes.

func (*Cluster) SendMsg

func (c *Cluster) SendMsg(sessionID uint64, data *protocol.SSMessage)

SendMsg Send message to specified node by session id.

func (*Cluster) Unpack

func (c *Cluster) Unpack(reader io.Reader) (payload *protocol.SSMessage, err error)

Unpack Decode messages that are communicated between cluster nodes.

type Event_OnConnect

type Event_OnConnect func(sessionID uint64, addr string)

type Event_OnDisconnect

type Event_OnDisconnect func(sessionID uint64, err error)

type Event_OnMessage

type Event_OnMessage func(sessionID uint64, msg *protocol.SSMessage)

type NodeConfig

type NodeConfig struct {
	NodeID     uint16 // 节点ID
	ListenAddr string // 监听地址 用于监听本地端口
	RemoteAddr string // 远端地址 用于
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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