pull

package
v1.0.0-preview Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2017 License: Apache-2.0 Imports: 8 Imported by: 548

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SelectEndpoints

func SelectEndpoints(k int, peerPool []discovery.NetworkMember) []*comm.RemotePeer

Types

type Mediator

type Mediator interface {
	// Stop stop the Mediator
	Stop()

	// RegisterMsgHook registers a message hook to a specific type of pull message
	RegisterMsgHook(PullMsgType, MessageHook)

	// Add adds a GossipMessage to the Mediator
	Add(*proto.GossipMessage)

	// Remove removes a GossipMessage from the Mediator
	Remove(*proto.GossipMessage)

	// HandleMessage handles a message from some remote peer
	HandleMessage(msg comm.ReceivedMessage)
}

Mediator is a component wrap a PullEngine and provides the methods it needs to perform pull synchronization.. The specialization of a pull mediator to a certain type of message is done by the configuration, a IdentifierExtractor, IdentifierExtractor given at construction, and also hooks that can be registered for each type of pullMsgType (hello, digest, req, res).

func NewPullMediator

func NewPullMediator(config PullConfig, sndr Sender, memSvc MembershipService, idExtractor proto.IdentifierExtractor, msgCons proto.MsgConsumer) Mediator

type MembershipService

type MembershipService interface {
	// GetMembership returns the membership of
	GetMembership() []discovery.NetworkMember
}

MembershipService obtains membership information of alive peers

type MessageHook

type MessageHook func(itemIds []string, items []*proto.GossipMessage, msg comm.ReceivedMessage)

MessageHook defines a function that will run after a certain pull message is received

type PullConfig

type PullConfig struct {
	Id                string
	PullInterval      time.Duration // Duration between pull invocations
	PeerCountToSelect int           // Number of peers to initiate pull with
	Tag               proto.GossipMessage_Tag
	Channel           common.ChainID
	MsgType           proto.PullMsgType
}

PullConfig defines the configuration of the pull mediator

type PullMsgType

type PullMsgType int

PullMsgType defines the type of a message that is sent to the PullStore

const (
	HelloMsgType PullMsgType = iota
	DigestMsgType
	RequestMsgType
	ResponseMsgType
)

type Sender

type Sender interface {
	// Send sends a message to a list of remote peers
	Send(msg *proto.GossipMessage, peers ...*comm.RemotePeer)
}

Jump to

Keyboard shortcuts

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