bmmc

package
v0.3.0 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: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NOCALLBACK is callback type for messages without callback
	NOCALLBACK = callback.NOCALLBACK
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BMMC added in v0.3.0

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

BMMC is the bimodal multicast protocol

func New

func New(cfg *Config) (*BMMC, error)

New creates a new instance for the protocol

func (*BMMC) AddMessage added in v0.3.0

func (b *BMMC) AddMessage(msg interface{}, callbackType string) error

AddMessage adds new message in messages buffer.

func (*BMMC) AddPeer added in v0.3.0

func (b *BMMC) AddPeer(addr, port string) error

AddPeer adds new peer in peers buffer

func (*BMMC) GetMessages added in v0.3.0

func (b *BMMC) GetMessages() []interface{}

GetMessages returns a slice with all messages from messages buffer

func (*BMMC) GetPeers added in v0.3.0

func (b *BMMC) GetPeers() []string

GetPeers returns an array with all peers from peers buffer

func (*BMMC) RemovePeer added in v0.3.0

func (b *BMMC) RemovePeer(addr, port string) error

RemovePeer removes given peer from peers buffer

func (*BMMC) Start added in v0.3.0

func (b *BMMC) Start() error

Start starts the gossip server and the http server

func (*BMMC) Stop added in v0.3.0

func (b *BMMC) Stop()

Stop stops the gossip server and the http server

type Config

type Config struct {
	// Addr is HTTP address for node which runs http servers
	// Required
	Addr string
	// Port is HTTP port for node which runs http servers
	// Required
	Port string
	// Beta is the expected fanout for gossip rounds
	// Optional
	Beta float64
	// Logger
	// Optional
	Logger *log.Logger
	// Callbacks funtions
	// Optional
	Callbacks map[string]func(interface{}, *log.Logger) error
	// Gossip round duration
	// Optional
	RoundDuration time.Duration
}

Config is the config for the protocol

type GossipRound added in v0.3.0

type GossipRound struct {
	Number int64       `json:"number"`
	Mux    *sync.Mutex `json:"mux"`
}

GossipRound is the number of gossiper rounds

func NewGossipRound added in v0.3.0

func NewGossipRound() *GossipRound

NewGossipRound creates new GossipRound

func (*GossipRound) GetNumber added in v0.3.0

func (r *GossipRound) GetNumber() int64

GetNumber returns the gossip round numbers

func (*GossipRound) Increment added in v0.3.0

func (r *GossipRound) Increment()

Increment increments the gossip round numbers

type HTTPGossip added in v0.3.0

type HTTPGossip struct {
	Addr        string              `json:"addr"`
	Port        string              `json:"port"`
	RoundNumber *GossipRound        `json:"roundNumber"`
	Digests     buffer.DigestBuffer `json:"digests"`
}

HTTPGossip is gossip message for http server

type HTTPSolicitation added in v0.3.0

type HTTPSolicitation struct {
	Addr        string              `json:"addr"`
	Port        string              `json:"port"`
	RoundNumber *GossipRound        `json:"roundNumber"`
	Digests     buffer.DigestBuffer `json:"digests"`
}

HTTPSolicitation is solicitation message for http server

type HTTPSynchronization added in v0.3.0

type HTTPSynchronization struct {
	Addr     string               `json:"addr"`
	Port     string               `json:"port"`
	Messages buffer.MessageBuffer `json:"messages"`
}

HTTPSynchronization is synchronization message for http server

Jump to

Keyboard shortcuts

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