Documentation ¶
Index ¶
- Constants
- type DigestFilter
- type PullAdapter
- type PullEngine
- func (engine *PullEngine) Add(seqs ...string)
- func (engine *PullEngine) OnDigest(digest []string, nonce uint64, context interface{})
- func (engine *PullEngine) OnHello(nonce uint64, context interface{})
- func (engine *PullEngine) OnReq(items []string, nonce uint64, context interface{})
- func (engine *PullEngine) OnRes(items []string, nonce uint64)
- func (engine *PullEngine) Remove(seqs ...string)
- func (engine *PullEngine) Stop()
- type PullEngineConfig
Constants ¶
const ( DefDigestWaitTime = 1000 * time.Millisecond DefRequestWaitTime = 1500 * time.Millisecond DefResponseWaitTime = 2000 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DigestFilter ¶
DigestFilter filters digests to be sent to a remote peer that sent a hello or a request, based on its messages's context
type PullAdapter ¶
type PullAdapter interface { // SelectPeers returns a slice of peers which the engine will initiate the protocol with SelectPeers() []string // Hello sends a hello message to initiate the protocol // and returns an NONCE that is expected to be returned // in the digest message. Hello(dest string, nonce uint64) // SendDigest sends a digest to a remote PullEngine. // The context parameter specifies the remote engine to send to. SendDigest(digest []string, nonce uint64, context interface{}) // SendReq sends an array of items to a certain remote PullEngine identified // by a string SendReq(dest string, items []string, nonce uint64) // SendRes sends an array of items to a remote PullEngine identified by a context. SendRes(items []string, context interface{}, nonce uint64) }
PullAdapter is needed by the PullEngine in order to send messages to the remote PullEngine instances. The PullEngine expects to be invoked with OnHello, OnDigest, OnReq, OnRes when the respective message arrives from a remote PullEngine
type PullEngine ¶
type PullEngine struct { PullAdapter // contains filtered or unexported fields }
PullEngine is the component that actually invokes the pull algorithm with the help of the PullAdapter
func NewPullEngine ¶
func NewPullEngine(participant PullAdapter, sleepTime time.Duration, config PullEngineConfig) *PullEngine
NewPullEngine creates an instance of a PullEngine with a certain sleep time between pull initiations
func NewPullEngineWithFilter ¶
func NewPullEngineWithFilter(participant PullAdapter, sleepTime time.Duration, df DigestFilter, config PullEngineConfig) *PullEngine
NewPullEngineWithFilter creates an instance of a PullEngine with a certain sleep time between pull initiations, and uses the given filters when sending digests and responses
func (*PullEngine) OnDigest ¶
func (engine *PullEngine) OnDigest(digest []string, nonce uint64, context interface{})
OnDigest notifies the engine that a digest has arrived
func (*PullEngine) OnHello ¶
func (engine *PullEngine) OnHello(nonce uint64, context interface{})
OnHello notifies the engine a hello has arrived
func (*PullEngine) OnReq ¶
func (engine *PullEngine) OnReq(items []string, nonce uint64, context interface{})
OnReq notifies the engine a request has arrived
func (*PullEngine) OnRes ¶
func (engine *PullEngine) OnRes(items []string, nonce uint64)
OnRes notifies the engine a response has arrived
func (*PullEngine) Remove ¶
func (engine *PullEngine) Remove(seqs ...string)
Remove removes items from the state