Documentation ¶
Index ¶
- Variables
- type Bucket
- func (bucket *Bucket) AddNewNode(n *commonModels.Node) *error.Error
- func (bucket *Bucket) AddSeed(node *commonModels.Node) *error.Error
- func (bucket *Bucket) Build(prop map[string]interface{})
- func (bucket *Bucket) CollectSeedFromConf()
- func (bucket *Bucket) GetNewBucket() map[int][]*commonModels.Node
- func (bucket *Bucket) GetRandomNode() *commonModels.Node
- func (bucket *Bucket) GetSeed() *commonModels.Node
- func (bucket *Bucket) IsNodeExist(n *commonModels.Node) bool
- type PingPongCachePackage
- type Shaker
- func (s Shaker) DoPing(targetIP string, targetServicePort string) interface{}
- func (s Shaker) DoPong(targetIP string, targetServicePort string) interface{}
- func (s Shaker) Send(message string, targetIP string, targetServicePort string) interface{}
- func (s *Shaker) SetNodeID(nodeID string)
- func (s *Shaker) SetSocketConn(socketConn *net.UDPConn)
Constants ¶
This section is empty.
Variables ¶
View Source
var NEW_BUCKET_COUNT int = 64
TODO 这些都加到配置里面8
View Source
var NEW_BUCKET_LENGTH int = 64
View Source
var TRIED_BUCKET_COUNT int = 64
View Source
var TRIED_BUCKET_LENGTH int = 16
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket 路由桶
func (*Bucket) AddNewNode ¶
func (bucket *Bucket) AddNewNode(n *commonModels.Node) *error.Error
AddNewNode 添加节点到新桶里
func (*Bucket) AddSeed ¶
func (bucket *Bucket) AddSeed(node *commonModels.Node) *error.Error
AddSeed 添加一个节点到种子 这里有可能是在初始化阶段就添加,也有可能在收到邻居信息的时候添加
func (*Bucket) CollectSeedFromConf ¶
func (bucket *Bucket) CollectSeedFromConf()
CollectSeedFromConf 从配置中获取种子
func (*Bucket) GetNewBucket ¶
func (bucket *Bucket) GetNewBucket() map[int][]*commonModels.Node
GetNewBucket 反射
func (*Bucket) GetRandomNode ¶
func (bucket *Bucket) GetRandomNode() *commonModels.Node
GetRandomNode 获得一个随机节点,给tcp服务进行连接尝试
func (*Bucket) IsNodeExist ¶
func (bucket *Bucket) IsNodeExist(n *commonModels.Node) bool
IsNodeExist 检查节点是否存在路由桶里
type PingPongCachePackage ¶
type PingPongCachePackage struct {
// contains filtered or unexported fields
}
PingPongCachePackage 处理PingPong的缓存数据
func CreatePingPongCache ¶
func CreatePingPongCache(nodeID string) *PingPongCachePackage
CreatePingPongCache 初始化一个缓存对象
func (*PingPongCachePackage) GetDoingPing ¶
func (c *PingPongCachePackage) GetDoingPing() bool
GetDoingPing 反射
func (*PingPongCachePackage) SetDoingPing ¶
func (c *PingPongCachePackage) SetDoingPing()
SetDoingPing 反射
func (*PingPongCachePackage) SetReceivePing ¶
func (c *PingPongCachePackage) SetReceivePing()
SetReceivePing 反射
func (*PingPongCachePackage) SetReceivePong ¶
func (c *PingPongCachePackage) SetReceivePong()
SetReceivePong 反射
type Shaker ¶
Shaker 握手对象handle
func (Shaker) DoPing ¶
*
- 处理Pong数据包
- @param targetIP string 目标IP
- @param targetServicePort string 目标服务端口
func (Shaker) DoPong ¶
*
- 处理Pong数据包
- @param targetIP string 目标IP
- @param targetServicePort string 目标服务端口
func (Shaker) Send ¶
*
- 把数据发送到目标地址
- @param message string 数据内容
- @param targetIP string 目标IP
- @param targetServicePort string 目标服务端口
func (*Shaker) SetSocketConn ¶
SetSocketConn 把socket设置进来
Click to show internal directories.
Click to hide internal directories.