service

package
v0.0.0-...-eeae653 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscoverService

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

DiscoverService 发现服务

func (*DiscoverService) Build

func (discoverService *DiscoverService) Build(conf interface{}, myPublicChanel map[string]chan map[string]interface{}) *error.Error

Build 构建发现服务

func (*DiscoverService) BuildPackageBody

func (discoverService *DiscoverService) BuildPackageBody(packType string, targetNodeID string) (string, *error.Error)

BuildPackageBody 构建一个规范的UDP包

func (*DiscoverService) DoPing

func (discoverService *DiscoverService) DoPing(targetIP string, targetServicePort string, nodeID string) interface{}

DoPing 处理Pong数据包 @param targetIP string 目标IP @param targetServicePort string 目标服务端口

func (*DiscoverService) DoPong

func (discoverService *DiscoverService) DoPong(targetIP string, targetServicePort string, nodeID string) interface{}

DoPong 处理Pong数据包 @param targetIP string 目标IP @param targetServicePort string 目标服务端口

func (*DiscoverService) DoSend

func (discoverService *DiscoverService) DoSend(message string, targetIP string, targetServicePort string) *error.Error

DoSend 把数据推送到消息发送队列中 @param message string 数据内容 @param targetIP string 目标IP @param targetServicePort string 目标服务端口

func (*DiscoverService) FormatBodyToString

func (discoverService *DiscoverService) FormatBodyToString(msgSource map[string]interface{}, targetNodeID string) (string, *error.Error)

FormatBodyToString 把带有msg的对象转换为协议数据包

func (*DiscoverService) GetFindNodePackString

func (discoverService *DiscoverService) GetFindNodePackString(findingNodeID string, targetNodeID string) string

GetFindNodePackString 构建一个邻居获取包 @param findingNodeID 需要查询的NodeID @param targetNodeID 目标结点NodeID

func (*DiscoverService) GetshareNodeNeighborPackString

func (discoverService *DiscoverService) GetshareNodeNeighborPackString(neighbors []*commonModels.Node, targetNodeID string) string

GetshareNodeNeighborPackString 构造邻居分享包

func (*DiscoverService) HandleDiscoverEventChanel

func (discoverService *DiscoverService) HandleDiscoverEventChanel()

HandleDiscoverEventChanel 处理发现服务的所有事件

func (*DiscoverService) HandleFindNode

func (discoverService *DiscoverService) HandleFindNode(data interface{}) (interface{}, *error.Error)

HandleFindNode 处理邻居节点寻找的请求

func (*DiscoverService) HandleShareNodeNeighbor

func (discoverService *DiscoverService) HandleShareNodeNeighbor(data interface{}) (interface{}, *error.Error)

HandleShareNodeNeighbor 处理邻居节点分享

func (*DiscoverService) ParseUDPData

func (discoverService *DiscoverService) ParseUDPData(udpData map[string]interface{}) (interface{}, *error.Error)

ParseUDPData 负责解析接收到的UDP数据包 @param data 从socket缓冲区中读取到的udp数据包 TODO 检查networkid、字段合法性、签名合法性问题

func (*DiscoverService) ProcessUDPData

func (discoverService *DiscoverService) ProcessUDPData(chanel chan map[string]interface{}, udpConn *net.UDPConn) *error.Error

ProcessUDPData 协程,负责读取udp数据

func (*DiscoverService) ReceiveMsg

func (discoverService *DiscoverService) ReceiveMsg(data interface{}) (interface{}, *error.Error)

ReceiveMsg 作为发现服务消息接收的入口

func (*DiscoverService) ReceivePing

func (discoverService *DiscoverService) ReceivePing(data interface{}) *error.Error

ReceivePing 接收Ping包的处理逻辑

func (*DiscoverService) ReceivePong

func (discoverService *DiscoverService) ReceivePong(data interface{}) *error.Error

ReceivePong 接收Pong包的所有处理逻辑

func (*DiscoverService) RunDoDiscover

func (discoverService *DiscoverService) RunDoDiscover(chanels map[string]chan map[string]interface{})

RunDoDiscover 主动寻找种子节点或邻居节点,进行连接

func (*DiscoverService) RunDoDiscoverByMasterArea

func (discoverService *DiscoverService) RunDoDiscoverByMasterArea(chanels map[string]chan map[string]interface{})

RunDoDiscoverByMasterArea 主动寻找种子节点或邻居节点,进行连接

func (*DiscoverService) RunService

func (discoverService *DiscoverService) RunService(chanels map[string]chan map[string]interface{}, signal chan bool) *error.Error

RunService 启动UDP服务器,并持续监听状态。 @param chanel 与消息队列通信的发现服务专用管道 @param signal 用于通知上级服务udp服务已就绪

func (*DiscoverService) Send

func (discoverService *DiscoverService) Send(message string, targetIP string, targetServicePort string) interface{}

Send 把数据发送到目标地址 @param message JSONstring 数据内容⭐message中必须带有nodeID字段 @param targetIP string 目标IP @param targetServicePort string 目标服务端口

func (*DiscoverService) SetPingCache

func (discoverService *DiscoverService) SetPingCache(data interface{}) *error.Error

SetPingCache 收到Ping包,设置对应的缓存 @param data udp数据包Json

func (*DiscoverService) SetPongCache

func (discoverService *DiscoverService) SetPongCache(data interface{}) *error.Error

SetPongCache 收到Pong包,设置对应的缓存 @param data udp数据包Json

Jump to

Keyboard shortcuts

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