node

package
v2.48.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 5 Imported by: 2

README

Reference node implementation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	NodeID string
	// contains filtered or unexported fields
}

Conn represents a connection to the orchestrator

func ConnectToOrchestrator

func ConnectToOrchestrator(bot Interface, addr string, nodeVersion string, id string, logger dshardorchestrator.Logger) (*Conn, error)

ConnectToOrchestrator attempts to connect to master, if it fails it will launch a reconnect loop and wait until the master appears

func NewNodeConn

func NewNodeConn(bot Interface, addr string, nodeVersion string, id string, logger dshardorchestrator.Logger) *Conn

NewNodeConn returns a new node connection

func (*Conn) Close

func (c *Conn) Close()

func (*Conn) GetIDLock

func (c *Conn) GetIDLock() string

func (*Conn) LogLock

func (c *Conn) LogLock(level dshardorchestrator.LogLevel, err error, msg string)

func (*Conn) Run

func (c *Conn) Run()

func (*Conn) Send

func (c *Conn) Send(evtID dshardorchestrator.EventType, body interface{}, queueFailed bool) error

Send sends the message to the master, if the connection is closed it will queue the message if queueFailed is set

func (*Conn) SendLogErr

func (c *Conn) SendLogErr(evtID dshardorchestrator.EventType, body interface{}, queueFailed bool)

type Interface

type Interface interface {
	SessionEstablished(info SessionInfo)

	// StopShard should disconnect the specific shard, and return the session info for resumes
	StopShard(shard int) (sessionID string, sequence int64, resumeGatewayUrl string)

	// ResumeShard should resume the speficic shard
	ResumeShard(shard int, sessionID string, sequence int64, resumeGatewayUrl string)

	// AddNewShards should add the following new shards to this node, doing the complete identify flow
	AddNewShards(shards ...int)

	// Caled when the bot should shut down, make sure to send EvtShutdown when completed
	Shutdown()

	// InitializeShardTransferFrom should prepare the shard for a outgoing transfer to another node, disconnecting it and returning the session info
	InitializeShardTransferFrom(shard int) (sessionID string, sequence int64, resumeGatewayUrl string)

	InitializeShardTransferTo(shard int, sessionID string, sequence int64, resumeGatewayUrl string)
	// StartShardTransferFrom should return when all user events has been sent, with the number of user events sent
	StartShardTransferFrom(shard int) (numEventsSent int)

	// HandleUserEvent should handle a user event, most commonly used for migrating data between shards during transfers
	HandleUserEvent(evt dshardorchestrator.EventType, data interface{})
}

type SessionInfo

type SessionInfo struct {
	TotalShards int
}

Jump to

Keyboard shortcuts

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