register

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DummyNode

type DummyNode struct {
	Id string
}

DummyNode is dummy, it has an ID field which will be using as primary key

func (*DummyNode) OwnsPayload

func (n *DummyNode) OwnsPayload(payload []byte) bool

func (*DummyNode) Payload

func (n *DummyNode) Payload() []byte

func (*DummyNode) PrimaryKey

func (n *DummyNode) PrimaryKey() string

type Node

type Node interface {
	PrimaryKey() string
	Payload() []byte

	// It knows if given payload was genereate from node
	OwnsPayload([]byte) bool
}

type NodeRegister

type NodeRegister struct {
	ZkServerAddresses string
	StateChan         chan ServiceState
	// contains filtered or unexported fields
}

NodeRegister is the low-level register for any type of nodes

func NewNodeRegister

func NewNodeRegister(zkServerAddresses string, baseKey string, node Node) *NodeRegister

func (*NodeRegister) DoRegister

func (r *NodeRegister) DoRegister() error

DoRegister register current node info to ZK Servers

func (*NodeRegister) EnsureConn

func (r *NodeRegister) EnsureConn() error

EnsureConn connects to zookeeper server if needed

func (*NodeRegister) GetRegisterKey

func (r *NodeRegister) GetRegisterKey() string

GetRegisterkey accepts a node and returns the key of zookeeper

func (*NodeRegister) SendEmptyEvent

func (r *NodeRegister) SendEmptyEvent()

func (*NodeRegister) StartDiscover

func (r *NodeRegister) StartDiscover(timeoutSeconds int) error

StartDiscover watch for new events on current cluster node, will retry on connection errors

func (*NodeRegister) Stop

func (r *NodeRegister) Stop() error

type ServiceState

type ServiceState struct {
	Nodes        int
	NodePayloads []string
	MyPostion    int
}

ServiceState is event for StartDiscover

Jump to

Keyboard shortcuts

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