Documentation ¶
Index ¶
- type Peer
- type Swarm
- func (s *Swarm) Close() error
- func (s *Swarm) Contains(ev event.Event) bool
- func (s *Swarm) Gossip() (complete mesh.GossipData)
- func (s *Swarm) ID() uint64
- func (s *Swarm) Join(peers ...string) (errs []error)
- func (s *Swarm) Listen(ctx context.Context)
- func (s *Swarm) Notify(ev event.Event, enabled bool)
- 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)
- func (s *Swarm) Printf(format string, args ...interface{})
- func (s *Swarm) SendTo(name mesh.PeerName, msg *message.Message) 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) Type ¶
func (p *Peer) Type() message.SubscriberType
Type returns the type of the subscriber.
type Swarm ¶
type Swarm struct { sync.Mutex OnSubscribe func(message.Subscriber, *event.Subscription) bool // Delegate to invoke when the subscription event is received. OnUnsubscribe func(message.Subscriber, *event.Subscription) bool // Delegate to invoke when the unsubscription event is received. OnDisconnect func(message.Subscriber, *event.Connection) bool // Delegate to invoke when the client is disconnected. 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) *Swarm
NewSwarm creates a new swarm messaging layer.
func (*Swarm) Contains ¶
Contains checks whether an event is currently triggered within the cluster.
func (*Swarm) Gossip ¶
func (s *Swarm) Gossip() (complete mesh.GossipData)
Gossip returns the state of everything we know; gets called periodically.
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.
func (*Swarm) OnGossipUnicast ¶
OnGossipUnicast occurs when the gossip unicast is received. In emitter this is used only to forward message frames around.