algo

package
v0.0.0-...-523a819 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDigestWaitTime

func SetDigestWaitTime(time time.Duration)

setDigestWaitTime设置摘要等待时间

func SetRequestWaitTime

func SetRequestWaitTime(time time.Duration)

setrequestwaittime设置请求等待时间

func SetResponseWaitTime

func SetResponseWaitTime(time time.Duration)

setResponseWaitTime设置响应等待时间

Types

type DigestFilter

type DigestFilter func(context interface{}) func(digestItem string) bool

DigestFilter筛选要发送到远程对等机的摘要 根据消息的上下文发送了问候或请求

type PullAdapter

type PullAdapter interface {
	//selectpeers返回一个对等机切片,引擎将使用该切片启动协议
	SelectPeers() []string

	//hello发送hello消息以启动协议
	//并返回一个期望返回的nonce
	//在摘要消息中。
	Hello(dest string, nonce uint64)

	//sendDigest将摘要发送到远程pullengine。
	//上下文参数指定要发送到的远程引擎。
	SendDigest(digest []string, nonce uint64, context interface{})

	//sendreq将一组项目发送到某个已标识的远程拉器引擎
	//用绳子
	SendReq(dest string, items []string, nonce uint64)

	//sendres将一组项目发送到由上下文标识的远程pullengine。
	SendRes(items []string, context interface{}, nonce uint64)
}

拉具发动机需要拉转接器,以便 向远程pullengine实例发送消息。 pullengine应该用 OnHello, OnDigest, OnReq, OnRes when the respective message arrives 从远程拉发动机

type PullEngine

type PullEngine struct {
	PullAdapter
	// contains filtered or unexported fields
}

pullengine是实际调用pull算法的组件 在PullAdapter的帮助下

func NewPullEngine

func NewPullEngine(participant PullAdapter, sleepTime time.Duration) *PullEngine

newpullengine创建具有特定睡眠时间的pullengine实例 在拉动启动之间

func NewPullEngineWithFilter

func NewPullEngineWithFilter(participant PullAdapter, sleepTime time.Duration, df DigestFilter) *PullEngine

newpullenginewithfilter创建具有特定睡眠时间的pullengine实例 在拉式启动之间,并在发送摘要和响应时使用给定的筛选器

func (*PullEngine) Add

func (engine *PullEngine) Add(seqs ...string)

添加将项添加到状态

func (*PullEngine) OnDigest

func (engine *PullEngine) OnDigest(digest []string, nonce uint64, context interface{})

OnDigest通知引擎摘要已到达

func (*PullEngine) OnHello

func (engine *PullEngine) OnHello(nonce uint64, context interface{})

OnHello通知引擎已到达Hello

func (*PullEngine) OnReq

func (engine *PullEngine) OnReq(items []string, nonce uint64, context interface{})

OnReq通知引擎请求已到达

func (*PullEngine) OnRes

func (engine *PullEngine) OnRes(items []string, nonce uint64)

OnRes通知引擎响应已到达

func (*PullEngine) Remove

func (engine *PullEngine) Remove(seqs ...string)

移除从状态中移除项

func (*PullEngine) Stop

func (engine *PullEngine) Stop()

停止停止发动机

Jump to

Keyboard shortcuts

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