gossip_model

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: 9 Imported by: 0

Documentation

Overview

Package gossip_model is a generated protocol buffer package.

It is generated from these files:

scuttlebutt_msgtest_export.proto

It has these top-level messages:

Test_Scuttlebutt_Peer
Test_Scuttlebutt

Index

Constants

This section is empty.

Variables

View Source
var BottomClock = limitClock(true) //earlier than anything

any other implement should consider these values before type switch, just like "nil"

View Source
var EmptyDigest = errors.New("digest is null")
View Source
var EmptyUpdate = errors.New("update is null")
View Source
var TopClock = limitClock(false) //later than anything

Functions

func DumpScuttlebutt

func DumpScuttlebutt(m *Model) *scuttlebuttStatus

func DumpUpdate

func DumpUpdate(u_in Update) (ret map[string]map[string]int)

func NewScuttlebuttStatus

func NewScuttlebuttStatus(gs ScuttlebuttStatus) *scuttlebuttStatus

func NewTestPeer

func NewTestPeer(t *testing.T, id string) *testPeer

func NewscuttlebuttDigest

func NewscuttlebuttDigest(gd Digest) *scuttlebuttDigest

func NewscuttlebuttUpdate

func NewscuttlebuttUpdate(gu Update) *scuttlebuttUpdateIn

func TestDigestToPb

func TestDigestToPb(d_in Digest) *pb.GossipMsg_Digest

func TestUpdateEncode

func TestUpdateEncode(u_in Update) *pb.GossipMsg_Update

Types

type Digest

type Digest interface{}

Base concept in gossip protocol

func TestPbToDigest

func TestPbToDigest(dig *pb.GossipMsg_Digest) Digest

type Model

type Model struct {
	sync.Mutex
	ReadOnly bool
	// contains filtered or unexported fields
}

Now we have the model

func NewGossipModel

func NewGossipModel(self Status) *Model

func (*Model) GenPullDigest

func (m *Model) GenPullDigest() Digest

gen the "pull" digest to far-end

func (*Model) RecvPullDigest

func (m *Model) RecvPullDigest(digests Digest) Update

recv the digest from a "pulling" far-end

func (*Model) RecvUpdate

func (m *Model) RecvUpdate(r Update) error

recv the reconciliation message and update status

func (*Model) Status

func (m *Model) Status() Status

func (*Model) TriggerReadOnlyMode

func (m *Model) TriggerReadOnlyMode(ro bool)

type Puller

type Puller struct {
	// contains filtered or unexported fields
}

func AcceptPulling

func AcceptPulling(p PushHelper, stream *pb.StreamHandler, model *Model, d Digest) (*Puller, error)

d can be set to nil and just return empty update (sometimes this indicate an "invitation" of pulling) Pulling process including two steps: 1. handling incoming digest and response a update 2. optional: start a "responding" pull the message among these two step is fixed: that is, the updating in step 1 must be sent after the digest sent in step 2 (unless step 2 is omitted)

The whole process is considered to be time-consuming: model and helper need to tailor the update to fit it into a suitable message size, and in a pulling process to decide a subset of peers in digest may require many evaluations

func NewPuller

func NewPuller(model *Model) *Puller

func StartPulling

func StartPulling(p PullerHelper, stream *pb.StreamHandler) (*Puller, error)

func (*Puller) NotifyUpdate

func (p *Puller) NotifyUpdate(ud Update) error

func (*Puller) Process

func (p *Puller) Process(ctx context.Context) error

func (*Puller) Start

func (p *Puller) Start(ph PullerHelper, stream *pb.StreamHandler) error

type PullerHelper

type PullerHelper interface {
	EncodeDigest(Digest) proto.Message
	//Handle method in PullerHandler is ensured to be called
	CanPull() *Puller
}

type PushHelper

type PushHelper interface {
	PullerHelper
	//must allow nil input and encode an message include "empty" update
	EncodeUpdate(Update) proto.Message
}

The push-pull model: peer can only trigger a "pushing" by start pulling and wait for another end do a "responding" pulling for it

type ScuttlebuttDigest

type ScuttlebuttDigest interface {
	GlobalDigest() Digest
	PeerDigest() []peersDig
	IsPartial() bool
}

type ScuttlebuttPeerStatus

type ScuttlebuttPeerStatus interface {
	To() VClock
	PickFrom(VClock, Update) (ScuttlebuttPeerUpdate, Update)
	Update(string, ScuttlebuttPeerUpdate, ScuttlebuttStatus) error
}

type ScuttlebuttPeerUpdate

type ScuttlebuttPeerUpdate interface {
	To() VClock
}

scuttlebutt scheme maintain per-peer status work with vclock digest

type ScuttlebuttStatus

type ScuttlebuttStatus interface {
	Status
	NewPeer(string) ScuttlebuttPeerStatus
	RemovePeer(string, ScuttlebuttPeerStatus)
	MissedUpdate(string, ScuttlebuttPeerUpdate) error
}

scuttlebuttStatusHelper provide a per-peer status managing

type ScuttlebuttUpdate

type ScuttlebuttUpdate interface {
	GlobalUpdate() Update
	PeerUpdate() []peersUpdate
}

type Status

type Status interface {
	GenDigest() Digest
	Update(Update) error
	MakeUpdate(Digest) Update
}

type TestPeer

type TestPeer interface {
	CreateModel() *Model
	LocalUpdate(ks []string)
	DumpPeers() []string
	DumpSelfData() map[string]int
	DumpData() map[string]int
}

type Test_Scuttlebutt

type Test_Scuttlebutt struct {
	Peers map[string]*Test_Scuttlebutt_Peer `` /* 130-byte string literal not displayed */
}

func (*Test_Scuttlebutt) Descriptor

func (*Test_Scuttlebutt) Descriptor() ([]byte, []int)

func (*Test_Scuttlebutt) GetPeers

func (m *Test_Scuttlebutt) GetPeers() map[string]*Test_Scuttlebutt_Peer

func (*Test_Scuttlebutt) ProtoMessage

func (*Test_Scuttlebutt) ProtoMessage()

func (*Test_Scuttlebutt) Reset

func (m *Test_Scuttlebutt) Reset()

func (*Test_Scuttlebutt) String

func (m *Test_Scuttlebutt) String() string

type Test_Scuttlebutt_Peer

type Test_Scuttlebutt_Peer struct {
	Datas map[string]int32 `` /* 131-byte string literal not displayed */
}

func (*Test_Scuttlebutt_Peer) Descriptor

func (*Test_Scuttlebutt_Peer) Descriptor() ([]byte, []int)

func (*Test_Scuttlebutt_Peer) GetDatas

func (m *Test_Scuttlebutt_Peer) GetDatas() map[string]int32

func (*Test_Scuttlebutt_Peer) ProtoMessage

func (*Test_Scuttlebutt_Peer) ProtoMessage()

func (*Test_Scuttlebutt_Peer) Reset

func (m *Test_Scuttlebutt_Peer) Reset()

func (*Test_Scuttlebutt_Peer) String

func (m *Test_Scuttlebutt_Peer) String() string

type Update

type Update interface {
	Gossip_IsUpdateIn() bool
}

Update is the content of a reconciliation

func TestUpdateDecode

func TestUpdateDecode(msg_in *pb.GossipMsg_Update) Update

type VClock

type VClock interface {
	Less(VClock) bool //VClock can be NEVER less than nil (indicate to "oldest" time)
}

VClock is a type of digest, indicate a partial order nature

Jump to

Keyboard shortcuts

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