gossip

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: BSD-3-Clause Imports: 8 Imported by: 2

Documentation

Overview

Package gossip defines an abstraction to gossip messages to a defined set of participants.

Documentation Last Review: 06.10.2020

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

type Actor interface {
	// SetPlayers changes the list of participants that the actor should send
	// rumors to. It is up to the implementation to send to only a subset.
	SetPlayers(mino.Players)

	// Add adds the rumor in the set of rumors that must be spread to the
	// participants.
	Add(rumor Rumor) error

	// Close cleans any resource used by the actor.
	Close() error
}

Actor is an actor that can send rumor to a gossip network.

type Flat

type Flat struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Flat is an implementation of a message passing protocol that is using a flat communication approach by sending a rumor to all the known participants.

- implements gossip.Gossiper

func NewFlat

func NewFlat(m mino.Mino, f serde.Factory) *Flat

NewFlat creates a new instance of a flat gossip protocol.

func (*Flat) Listen

func (flat *Flat) Listen() (Actor, error)

Listen implements gossip.Gossiper. It creates the RPC and starts to listen for incoming rumors while spreading its own ones.

func (*Flat) Rumors

func (flat *Flat) Rumors() <-chan Rumor

Rumors implements gossip.Gossiper. It returns the channel that is populated with new rumors.

type Gossiper

type Gossiper interface {
	// Rumors returns a channel populated with the new rumors.
	Rumors() <-chan Rumor

	// Listen starts to listen for rumors and returns a gossip actor.
	Listen() (Actor, error)
}

Gossiper is an abstraction of a message passing protocol that uses internally a gossip protocol.

type Rumor

type Rumor interface {
	serde.Message

	// GetID returns the unique identifier of the rumor.
	GetID() []byte
}

Rumor is the message that must be gossiped through the network. It is using the identifier as a unique way to differentiate all the rumors.

Jump to

Keyboard shortcuts

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