services

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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var INBOUND_CONN_MAX int = 1000
View Source
var OUTBOUND_CONN_MAX int = 8

Functions

This section is empty.

Types

type NodeConnectionService

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

NodeConnectionService 节点连接服务的tcp handle

func (*NodeConnectionService) AddInBoundConn

func (ncService *NodeConnectionService) AddInBoundConn(nodeConn *nodeConnectionModels.NodeConn) *error.Error

AddInBoundConn 添加一个InBound连接

func (*NodeConnectionService) AddInBoundSocket

func (ncService *NodeConnectionService) AddInBoundSocket(nodeConn *nodeConnectionModels.NodeConn) *error.Error

AddInBoundSocket 添加一个被链接的socket, 被连接的socket还是多多益善吧

func (*NodeConnectionService) AddMasterInBoundConn

func (ncService *NodeConnectionService) AddMasterInBoundConn(nodeConn *nodeConnectionModels.NodeConn) *error.Error

AddMasterInBoundConn 添加一个InBound连接

func (*NodeConnectionService) AddMasterOutBoundConn

func (ncService *NodeConnectionService) AddMasterOutBoundConn(nodeConn *nodeConnectionModels.NodeConn) *error.Error

AddMasterOutBoundConn 添加一个InBound连接

func (*NodeConnectionService) AddOutBoundConn

func (ncService *NodeConnectionService) AddOutBoundConn(nodeConn *nodeConnectionModels.NodeConn) *error.Error

AddOutBoundConn 添加一个InBound连接

func (*NodeConnectionService) Build

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

Build 节点通讯服务的初始化

func (*NodeConnectionService) CheckBoundAddress

func (ncService *NodeConnectionService) CheckBoundAddress(ip string, servicePort string) bool

CheckBoundAddress 检查本地是否已经和这个ip:port连接过。

func (*NodeConnectionService) DeleteInBoundConn

func (ncService *NodeConnectionService) DeleteInBoundConn(nodeConn *nodeConnectionModels.NodeConn) *error.Error

DeleteInBoundConn 添加一个InBound连接

func (*NodeConnectionService) DeleteMasterInBoundConn

func (ncService *NodeConnectionService) DeleteMasterInBoundConn(nodeConn *nodeConnectionModels.NodeConn) *error.Error

DeleteMasterInBoundConn 添加一个InBound连接

func (*NodeConnectionService) DeleteMasterOutBoundConn

func (ncService *NodeConnectionService) DeleteMasterOutBoundConn(nodeConn *nodeConnectionModels.NodeConn) *error.Error

DeleteMasterOutBoundConn 添加一个InBound连接

func (*NodeConnectionService) DeleteOutBoundConn

func (ncService *NodeConnectionService) DeleteOutBoundConn(nodeConn *nodeConnectionModels.NodeConn) *error.Error

DeleteOutBoundConn 添加一个InBound连接

func (*NodeConnectionService) DeleteUnShakedNodeConn

func (ncService *NodeConnectionService) DeleteUnShakedNodeConn(remoteNodeID string)

DeleteUnShakedNodeConn 由于这个remoteNodeID已经握手成功,所以要把同ID,但未握手成功的节点清理掉

func (*NodeConnectionService) DoFindConnectionByNodeList

func (ncService *NodeConnectionService) DoFindConnectionByNodeList(chanels map[string]chan map[string]interface{})

DoFindConnectionByNodeList 主动找可用节点

func (*NodeConnectionService) DoFindConnectionByNodeListAndMasterArea

func (ncService *NodeConnectionService) DoFindConnectionByNodeListAndMasterArea(chanels map[string]chan map[string]interface{})

DoFindConnectionByNodeListAndMasterArea 主动找可用节点 Master算法中,区域master结点优先与其他区域的Master结点发起连接,没有的话就与NodeList第一位发起连接。 而普通结点优先与本区域的Master结点发起连接,没有Master就与区域的其他结点发起连接,本区域其他结点都没有了,就与NodeList第一位发起连接

func (*NodeConnectionService) GetFindNodePackString

func (ncService *NodeConnectionService) GetFindNodePackString(findingNodeID string, targetNodeID string) string

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

func (*NodeConnectionService) GetOutBoundSocket

func (ncService *NodeConnectionService) GetOutBoundSocket(newNode *commonModels.Node, targetNodeID string) (*net.Conn, bool, *error.Error)

GetOutBoundSocket 根据目标节点,创建一个可用的socket @param newNode 目标节点,主要为了获取IP port @param targetNodeID 子节点ID @return nodeConn 带socket的nodeConn对象 @return isNew 是否新对象,如果是新socket,要读数据 @return error 错误

func (*NodeConnectionService) GetShakePackString

func (ncService *NodeConnectionService) GetShakePackString(shaketype string, targetNodeID string) string

GetShakePackString 获取一个握手包

func (*NodeConnectionService) GetStatus

func (ncService *NodeConnectionService) GetStatus() map[string]interface{}

GetStatus 获取节点当前状态

func (*NodeConnectionService) GetshareNodeNeighborPackString

func (ncService *NodeConnectionService) GetshareNodeNeighborPackString(neighbors []*commonModels.Node, targetNodeID string) string

GetshareNodeNeighborPackString 构造邻居分享包

func (*NodeConnectionService) HandleFindNode

func (ncService *NodeConnectionService) HandleFindNode(data interface{}) (interface{}, *error.Error)

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

func (*NodeConnectionService) HandleNodeConnectionEventChanel

func (ncService *NodeConnectionService) HandleNodeConnectionEventChanel()

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

func (*NodeConnectionService) HandleShakeBackAgainEvent

func (ncService *NodeConnectionService) HandleShakeBackAgainEvent(data interface{}) (interface{}, *error.Error)

HandleShakeBackAgainEvent 只有inBound的连接才会给你发shakeBackAgain

func (*NodeConnectionService) HandleShakeBackEvent

func (ncService *NodeConnectionService) HandleShakeBackEvent(data interface{}) (interface{}, *error.Error)

HandleShakeBackEvent 只有outBound的连接才会给你发shakeBack

func (*NodeConnectionService) HandleShakeDestroyEvent

func (ncService *NodeConnectionService) HandleShakeDestroyEvent(data interface{}) (interface{}, *error.Error)

HandleShakeDestroyEvent 对方节点要求断开主动连接的事件请求

func (*NodeConnectionService) HandleShakeEvent

func (ncService *NodeConnectionService) HandleShakeEvent(data interface{}) (interface{}, *error.Error)

HandleShakeEvent 处理接收nodeConnetion消息 只有inBound连接,才有可能收到shakerEvent,所以收到shake就必然回复一个shakeBack

func (*NodeConnectionService) HandleShareNodeNeighbor

func (ncService *NodeConnectionService) HandleShareNodeNeighbor(data interface{}) (interface{}, *error.Error)

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

func (*NodeConnectionService) IsBucketExistShakedNode

func (ncService *NodeConnectionService) IsBucketExistShakedNode(nodeID string) bool

IsBucketExistShakedNode 检查这个nodeID是否被链接上,只查找已经握手成功的,为了防止重复shakeBack

func (*NodeConnectionService) IsBucketExistUnShakedNode

func (ncService *NodeConnectionService) IsBucketExistUnShakedNode(nodeID string) bool

IsBucketExistUnShakedNode 检查这个nodeID是否被链接上,只查找还没握手成功的。为了防止重复outBound

func (*NodeConnectionService) IsInBoundFull

func (ncService *NodeConnectionService) IsInBoundFull() bool

IsInBoundFull 检查outbound连接是否满了

func (*NodeConnectionService) IsOutBoundFull

func (ncService *NodeConnectionService) IsOutBoundFull() bool

IsOutBoundFull 检查outbound连接是否满了

func (*NodeConnectionService) MasterDoTryOutBoundConnect

func (ncService *NodeConnectionService) MasterDoTryOutBoundConnect(newNode *commonModels.Node, targetNodeID string) (map[string]interface{}, *error.Error)

MasterDoTryOutBoundConnect master节点尝试建立连接,并创建一个NodeConn返回(端口多路复用函数 @param newNode 目标连接节点IP @param targetNodeID 发起连接的本地节点ip

func (*NodeConnectionService) MasterProcessOutboundTCPData

func (ncService *NodeConnectionService) MasterProcessOutboundTCPData(nodeConn *nodeConnectionModels.NodeConn)

MasterProcessOutboundTCPData 狂读TCP socket(端口多路复用函数

func (*NodeConnectionService) ParseTCPData

func (ncService *NodeConnectionService) ParseTCPData(tcpSourceData string) (interface{}, *error.Error)

ParseTCPData 解析TCP数据包

func (*NodeConnectionService) ProcessInboundTCPData

func (ncService *NodeConnectionService) ProcessInboundTCPData(nodeConn *nodeConnectionModels.NodeConn)

ProcessInboundTCPData 狂读TCP socket

func (*NodeConnectionService) ProcessOutboundTCPData

func (ncService *NodeConnectionService) ProcessOutboundTCPData(nodeConn *nodeConnectionModels.NodeConn)

ProcessOutboundTCPData 狂读TCP socket

func (*NodeConnectionService) ReceiveMsg

func (ncService *NodeConnectionService) ReceiveMsg(data interface{}) (interface{}, *error.Error)

ReceiveMsg 处理接收nodeConnetion消息,这里主要做分流

func (*NodeConnectionService) RunFindConnection

func (ncService *NodeConnectionService) RunFindConnection(chanels map[string]chan map[string]interface{})

RunFindConnection 主动找可用节点

func (*NodeConnectionService) RunFindConnectionByMasterArea

func (ncService *NodeConnectionService) RunFindConnectionByMasterArea(chanels map[string]chan map[string]interface{})

RunFindConnectionByMasterArea 主动找可用节点(使用master结点算法的查找)

func (*NodeConnectionService) RunMonitor

func (ncService *NodeConnectionService) RunMonitor()

RunMonitor 监控InBound和outBound的情况。nodeID长期为空的

func (*NodeConnectionService) RunService

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

RunService 启动节点通信的TCP相关服务

func (*NodeConnectionService) SalveHandleNodeInBoundConnectionCreateEvent

func (ncService *NodeConnectionService) SalveHandleNodeInBoundConnectionCreateEvent(nodeConnectionCreateResp map[string]interface{})

SalveHandleNodeInBoundConnectionCreateEvent 子节点处理节点创建成功事件。(但是不知道应该给哪个子节点)

func (*NodeConnectionService) SalveHandleNodeOutBoundConnectionCreateEvent

func (ncService *NodeConnectionService) SalveHandleNodeOutBoundConnectionCreateEvent(nodeConnectionCreateResp map[string]interface{})

SalveHandleNodeOutBoundConnectionCreateEvent 子节点处理节点创建成功事件。

func (*NodeConnectionService) Send

func (ncService *NodeConnectionService) Send(nodeConn *nodeConnectionModels.NodeConn, message string)

Send 底层tcp发包

Jump to

Keyboard shortcuts

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