Documentation ¶
Index ¶
- type Config
- type Delegate
- type EventsDelegate
- type Gossip
- func (g *Gossip) GetPool(id int32) *Pool
- func (g *Gossip) ListPools() []int32
- func (g *Gossip) Listen(id uint16) (net.Listener, error)
- func (g *Gossip) ListenTCP() net.Listener
- func (g *Gossip) RegisterPool(pconf *PoolConfig) *Pool
- func (g *Gossip) Start() (err error)
- func (g *Gossip) UDPPackets() <-chan *memberlist.Packet
- type Pool
- type PoolConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Name string AdvertiseAddr string AdvertisePort int BindAddr string BindPort int PublicKey []byte // Public key for the node Coordinate *vivaldi.Config Logger *log.Logger Debug bool // Turn on debug }
Config holds the config instantiate a Gossip instance
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a default config to instantiate a Gossip instance
type Delegate ¶
type Delegate interface { NotifyMsg(msg []byte) MergeRemoteState(remote *net.TCPAddr, buf []byte, join bool) LocalState(join bool) []byte }
Delegate is the overwritten memberlist delegate
type EventsDelegate ¶
type EventsDelegate interface { NotifyJoin(*peerspb.Peer) NotifyUpdate(*peerspb.Peer) NotifyLeave(*peerspb.Peer) }
EventsDelegate implements in interface called on member events
type Gossip ¶
type Gossip struct {
// contains filtered or unexported fields
}
Gossip is the top-level gossip struct to manage multiple pools
func (*Gossip) GetPool ¶
GetPool returns a gossip pool by the given id. It returns nil if the pool id does not exist
func (*Gossip) Listen ¶
Listen returns a new muxed listener by the given id. The dialer must send the same id at the time of connection. It returns an error if the id is taken. All listeners must be registered before gossip is actually started as the addition of listeners is not thread-safe
func (*Gossip) ListenTCP ¶
ListenTCP returns a TCP Listener interface for native non-muxed protocols. This does not actually start listening but rather returns a Listener interface backed by a channel of incoming connections
func (*Gossip) RegisterPool ¶
func (g *Gossip) RegisterPool(pconf *PoolConfig) *Pool
RegisterPool creates a new gossip pool with the given config. All pools must be registered before gossip is started as the addition of pools is not thread-safe
func (*Gossip) Start ¶
Start starts the underlying transport and all registered gossip pools This should be called only after all pools have been registered
func (*Gossip) UDPPackets ¶
func (g *Gossip) UDPPackets() <-chan *memberlist.Packet
UDPPackets returns a read-only channel incoming non-gossip udp packets. This is useful for custom application transport allowing network communication on a single port
type Pool ¶
type Pool struct { // memberlist for pool *memberlist.Memberlist // contains filtered or unexported fields }
Pool is a single gossip pool
func NewPool ¶
func NewPool(conf *PoolConfig) *Pool
NewPool returns a new gossip pool using the given config
type PoolConfig ¶
type PoolConfig struct { ID int32 Peers peers.Library Vivaldi *vivaldi.Client Memberlist *memberlist.Config Delegate Delegate Events EventsDelegate Logger *log.Logger Debug bool }
PoolConfig is the config for a single gossip pool
func DefaultLANPoolConfig ¶
func DefaultLANPoolConfig(id int32) *PoolConfig
DefaultLANPoolConfig returns a sane config suitable for LAN based pool
func DefaultLocalPoolConfig ¶
func DefaultLocalPoolConfig(id int32) *PoolConfig
DefaultLocalPoolConfig returns a sane config suitable for local pool
func DefaultPoolConfig ¶
func DefaultPoolConfig(id int32) *PoolConfig
DefaultPoolConfig returns a base config to init a new gossip pool
func DefaultWANPoolConfig ¶
func DefaultWANPoolConfig(id int32) *PoolConfig
DefaultWANPoolConfig returns a sane config suitable for WAN based pool