gossip

package
v0.0.0-...-667e438 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultErrorLimit = 3 //peer is allowed to violate policy 3 times/min
View Source
var DefaultInterval = int64(60)
View Source
var DefaultMsgSize = 1024 * 1024 * 16 //msg limit is 16kB/s
View Source
var ObtainHandler func(*pb.StreamHandler) GossipHandler

Functions

func NewCatalogHandlerImpl

func NewCatalogHandlerImpl(stub *pb.StreamStub, ctx context.Context, helper CatalogHelper, m *model.Model) (ret *catalogHandler)

func NewCatalogPolicyDefault

func NewCatalogPolicyDefault() (ret *catalogPolicyImpl)

func NewTokenBucket

func NewTokenBucket(inv int) *tokenBucket

Types

type CatalogHandler

type CatalogHandler interface {
	Name() string
	Model() *model.Model
	//just notify the model is updated
	SelfUpdate(...*pb.PeerID)
	HandleUpdate(*pb.GossipMsg_Update, CatalogPeerPolicies)
	HandleDigest(*pb.StreamHandler, *pb.GossipMsg_Digest, CatalogPeerPolicies)
}

type CatalogHelper

type CatalogHelper interface {
	Name() string
	GetPolicies() CatalogPolicies //caller do not need to check the interface

	TransDigestToPb(model.Digest) *pb.GossipMsg_Digest
	TransPbToDigest(*pb.GossipMsg_Digest) model.Digest

	TransUpdateToPb(CatalogPeerPolicies, model.Update) *pb.GossipMsg_Update
	TransPbToUpdate(CatalogPeerPolicies, *pb.GossipMsg_Update) (model.Update, error)
}

type CatalogPeerPolicies

type CatalogPeerPolicies interface {
	GetId() string //equal to peerId.GetName()
	AllowRecvUpdate() bool
	PushUpdateQuota() int
	PushUpdate(int)
	RecordViolation(error)
	ScoringPeer(s int, weight uint)
}

type CatalogPolicies

type CatalogPolicies interface {
	AllowRecvUpdate() bool //the catalogy allow response a pull when accepting pulling from far-end
	PushCount() int        //how many push expected to do in one schedule gossip work
	MaxTrackPeers() int    //how many peers the catalog should track
	PullTimeout() int      //in seconds
}

type GossipHandler

type GossipHandler interface {
	HandleMessage(*pb.StreamHandler, *pb.GossipMsg) error
	Stop()
}

the simplified stream handler

type GossipStub

type GossipStub struct {
	*pb.StreamStub
	peerACL.AccessControl
	// contains filtered or unexported fields
}

GossipStub struct

func NewGossipWithPeer

func NewGossipWithPeer(p peer.Peer) *GossipStub

func (*GossipStub) AddCatalogHandler

func (g *GossipStub) AddCatalogHandler(h CatalogHandler)

func (*GossipStub) CreateGossipHandler

func (g *GossipStub) CreateGossipHandler(id *pb.PeerID) GossipHandler

func (*GossipStub) GetCatalogHandler

func (g *GossipStub) GetCatalogHandler(cat string) CatalogHandler

func (*GossipStub) GetSStub

func (g *GossipStub) GetSStub() *pb.StreamStub

func (*GossipStub) GetSelf

func (g *GossipStub) GetSelf() *pb.PeerID

func (*GossipStub) GetStubContext

func (g *GossipStub) GetStubContext() context.Context

func (*GossipStub) NotifyNewPeer

func (g *GossipStub) NotifyNewPeer(peerid *pb.PeerID, _ *pb.StreamStub)

func (*GossipStub) SubScribeNewPeerNotify

func (g *GossipStub) SubScribeNewPeerNotify(h CatalogHandler)

type PeerPolicies

type PeerPolicies interface {
	GetId() string
	IsPolicyViolated() error
	RecvUpdate(int)
	RecordViolation(e error)
	AllowRecvUpdate() bool
	PushUpdateQuota() int
	PushUpdate(int)
	ScoringPeer(int, uint)
	ResetIntervals(int)
}

func NewPeerPolicy

func NewPeerPolicy(id string) PeerPolicies

Directories

Path Synopsis
Package gossip_model is a generated protocol buffer package.
Package gossip_model is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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