Documentation ¶
Index ¶
- type Peer
- type SubscriptionEvent
- type Swarm
- func (s *Swarm) Close() error
- func (s *Swarm) FindPeer(name mesh.PeerName) *Peer
- func (s *Swarm) Gossip() (complete mesh.GossipData)
- func (s *Swarm) ID() uint64
- func (s *Swarm) Join(peers ...string) (errs []error)
- func (s *Swarm) Listen()
- func (s *Swarm) NotifySubscribe(conn security.ID, ssid message.Ssid)
- func (s *Swarm) NotifyUnsubscribe(conn security.ID, ssid message.Ssid)
- func (s *Swarm) NumPeers() int
- func (s *Swarm) OnGossip(buf []byte) (delta mesh.GossipData, err error)
- func (s *Swarm) OnGossipBroadcast(src mesh.PeerName, buf []byte) (delta mesh.GossipData, err error)
- func (s *Swarm) OnGossipUnicast(src mesh.PeerName, buf []byte) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Peer ¶
Peer represents a remote peer.
func (*Peer) Close ¶
func (p *Peer) Close()
Close termintes the peer and stops everything associated with this peer.
func (*Peer) Type ¶
func (p *Peer) Type() message.SubscriberType
Type returns the type of the subscriber.
type SubscriptionEvent ¶
type SubscriptionEvent struct { Ssid message.Ssid // The SSID for the subscription. Peer mesh.PeerName // The name of the peer. Conn security.ID // The connection identifier. }
SubscriptionEvent represents a subscription event.
func (*SubscriptionEvent) Encode ¶
func (e *SubscriptionEvent) Encode() string
Encode encodes the event to string representation.
type Swarm ¶
type Swarm struct { sync.Mutex OnSubscribe func(message.Ssid, message.Subscriber) bool // Delegate to invoke when the subscription event is received. OnUnsubscribe func(message.Ssid, message.Subscriber) bool // Delegate to invoke when the subscription event is received. OnMessage func(*message.Message) // Delegate to invoke when a new message is received. // contains filtered or unexported fields }
Swarm represents a gossiper.
func NewSwarm ¶
func NewSwarm(cfg *config.ClusterConfig, closing chan bool) *Swarm
NewSwarm creates a new swarm messaging layer.
func (*Swarm) Gossip ¶
func (s *Swarm) Gossip() (complete mesh.GossipData)
Gossip returns the state of everything we know; gets called periodically.
func (*Swarm) NotifySubscribe ¶
NotifySubscribe notifies the swarm when a subscription occurs.
func (*Swarm) NotifyUnsubscribe ¶
NotifyUnsubscribe notifies the swarm when an unsubscription occurs.
func (*Swarm) OnGossip ¶
func (s *Swarm) OnGossip(buf []byte) (delta mesh.GossipData, err error)
OnGossip merges received data into state and returns "everything new I've just learnt", or nil if nothing in the received data was new.
func (*Swarm) OnGossipBroadcast ¶
OnGossipBroadcast merges received data into state and returns a representation of the received data (typically a delta) for further propagation.