Documentation ¶
Index ¶
- Constants
- type BMMC
- func (b *BMMC) AddMessage(msg any, callbackType string) error
- func (b *BMMC) AddPeer(p string) error
- func (b *BMMC) GetMessages() []any
- func (b *BMMC) GetPeers() []string
- func (b *BMMC) GossipHandler(body []byte)
- func (b *BMMC) RemovePeer(p string) error
- func (b *BMMC) SolicitationHandler(body []byte)
- func (b *BMMC) Start() error
- func (b *BMMC) Stop()
- func (b *BMMC) SynchronizationHandler(body []byte)
- type Config
- type Gossip
- type GossipRound
- type Solicitation
- type Synchronization
Constants ¶
const ( // GossipRoute is the route for gossip messages. GossipRoute = "/gossip" // SolicitationRoute is the route for solicitation messages. SolicitationRoute = "/solicitation" // SynchronizationRoute is the route for synchronization messages. SynchronizationRoute = "/synchronization" )
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 (*BMMC) AddMessage ¶ added in v0.3.0
AddMessage adds new message in messages buffer.
func (*BMMC) GetMessages ¶ added in v0.3.0
GetMessages returns a slice with all user messages from messages buffer.
func (*BMMC) GossipHandler ¶ added in v0.7.0
GossipHandler handles a gossip message.
func (*BMMC) RemovePeer ¶ added in v0.3.0
RemovePeer removes given peer from peers buffer.
func (*BMMC) SolicitationHandler ¶ added in v0.7.0
SolicitationHandler handles a solicitation message.
func (*BMMC) Stop ¶ added in v0.3.0
func (b *BMMC) Stop()
Stop stops the gossip server and the http server.
func (*BMMC) SynchronizationHandler ¶ added in v0.7.0
SynchronizationHandler handles a synchronization message.
type Config ¶
type Config struct { // Host is the host peer. // Required. Host peer.Peer // Beta is the expected fanout for gossip rounds. // Optional Beta float64 // Logger. // Optional Logger *slog.Logger // Callbacks functions. // Optional Callbacks map[string]func(any, *slog.Logger) error // Gossip round duration. // Optional RoundDuration time.Duration // Buffer size. // When the buffer is full, the oldest message will be removed. // Required BufferSize int }
Config is the config for the protocol.
type Gossip ¶ added in v0.7.0
type Gossip struct { Host string `json:"host"` RoundNumber *GossipRound `json:"roundNumber"` Digest []string `json:"digest"` }
Gossip is gossip message for http server.
type GossipRound ¶ added in v0.3.0
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 Solicitation ¶ added in v0.7.0
type Solicitation struct { Host string `json:"host"` RoundNumber *GossipRound `json:"roundNumber"` Digest []string `json:"digest"` }
Solicitation is solicitation message for server.
type Synchronization ¶ added in v0.7.0
type Synchronization struct { Host string `json:"host"` Elements []buffer.Element `json:"elements"` }
Synchronization is synchronization message for server.