device

package
v0.0.0-...-cf8e561 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocateNewNode

func AllocateNewNode(dID int) (int, error)

为device分配新节点,返回新节点的ID

func Balance

func Balance() (int, error)

负载均衡算法-待优化

func FindNodeIDRedis

func FindNodeIDRedis(dID int) (int, error)

在redis中查找dID对应的nodeid

func FindNodeInfoRedis

func FindNodeInfoRedis(nodeID int) (node *db.Node)

在redis中查找nodeID对应的node信息

func FindNodeNow

func FindNodeNow(dID int) (node *db.Node)
传入dID,查找其对应的node信息

如果对应的node节点下线,则为device分配新node

func FindNowNodeIDMysql

func FindNowNodeIDMysql(dID int) (int, error)
通过dID,在MySQL中查找nodeID。

注意!此函数适合查找dID所对应当前最新的nodeID,不适合查找过去的node列表

func InsertDNodeMysql

func InsertDNodeMysql(dID int, device *db.Device) error

将dID与nodeID的映射写入mysql

func InsertDNodeRedis

func InsertDNodeRedis(dID int, nodeID int) error

将dID与nodeID的映射写入Redis,传入dID和nodeID

Types

type NodeWithTime

type NodeWithTime struct {
	Itime time.Time
	Addr  string
	Port  int
}

func FindNodeIDMysql

func FindNodeIDMysql(dID int) (nodes []NodeWithTime)
在MySQL中 通过dID寻找对应的node信息及开始保存在此node的时间戳

nodes信息为之前绑定的节点,返回整个列表

Jump to

Keyboard shortcuts

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