session

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 22 Imported by: 6

Documentation

Index

Constants

View Source
const (
	NoErr = iota
	TransportErr
	NodeStopErr
	QueueShutdownErr
)

session termination error type

Variables

View Source
var ErrWaitTimeout = errors.New("timed out waiting for the condition")

ErrWaitTimeout is returned when the condition exited without success.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// NodeNumber is the number of currently connected edge
	// nodes for single cloudHub instance
	NodeNumber int32
	// NodeLimit is the maximum number of edge nodes that can
	// connected to single cloudHub instance
	NodeLimit int32
	// NodeSessions maps a node ID to NodeSession
	NodeSessions sync.Map
}

func NewSessionManager

func NewSessionManager(nodeLimit int32) *Manager

NewSessionManager initializes a new SessionManager

func (*Manager) AddSession

func (sm *Manager) AddSession(session *NodeSession)

AddSession add node session to the session manager

func (*Manager) DeleteSession

func (sm *Manager) DeleteSession(session *NodeSession)

DeleteSession delete the node session from session manager

func (*Manager) GetSession

func (sm *Manager) GetSession(nodeID string) (*NodeSession, bool)

GetSession get the node session for the node

func (*Manager) KeepAliveMessage

func (sm *Manager) KeepAliveMessage(nodeID string) error

KeepAliveMessage receive keepalive message from edge node

func (*Manager) ReachLimit

func (sm *Manager) ReachLimit() bool

ReachLimit checks whether the connected nodes exceeds the node limit number

func (*Manager) ReceiveMessageAck

func (sm *Manager) ReceiveMessageAck(nodeID, parentID string) error

ReceiveMessageAck receive the message ack from edge node

type NodeSession

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

NodeSession is an abstraction of a node connection lifecycle.

func NewNodeSession

func NewNodeSession(
	nodeID, projectID string,
	connection conn.Connection,
	keepaliveInterval time.Duration,
	nodeMessagePool *common.NodeMessagePool,
	reliableClient reliableclient.Interface,
) *NodeSession

func (*NodeSession) GetTerminateErr

func (ns *NodeSession) GetTerminateErr() int32

func (*NodeSession) KeepAliveCheck

func (ns *NodeSession) KeepAliveCheck()

KeepAliveCheck A goroutine running KeepAliveCheck is started for each connection.

func (*NodeSession) KeepAliveMessage

func (ns *NodeSession) KeepAliveMessage()

KeepAliveMessage receive keepalive message from edge node

func (*NodeSession) ReceiveMessageAck

func (ns *NodeSession) ReceiveMessageAck(parentID string)

ReceiveMessageAck receive the message ack from edge node

func (*NodeSession) SendAckMessage

func (ns *NodeSession) SendAckMessage()

SendAckMessage loops forever sending message that require acknowledgment to the edge node until an error is encountered (or the connection is closed).

func (*NodeSession) SendNoAckMessage

func (ns *NodeSession) SendNoAckMessage()

SendNoAckMessage loops forever sending the message that does not require acknowledgment to the edge node until an error is encountered (or the connection is closed).

func (*NodeSession) SetTerminateErr

func (ns *NodeSession) SetTerminateErr(terminateErr int32)

func (*NodeSession) Start

func (ns *NodeSession) Start()

Start the main goroutine responsible for serving node session

func (*NodeSession) Terminating

func (ns *NodeSession) Terminating()

Terminating terminates the node session and it is called when the client goes offline, It will shutdown the message queue and the goroutine associated with it will exit.

Jump to

Keyboard shortcuts

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