pubsub

package
v0.8.83 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0, AGPL-3.0-or-later, Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrPubsubNotInit      warpnet.WarpError = "gossip: service not initialized"
	ErrAlreadyRunning     warpnet.WarpError = "gossip: pubsub is already running"
	ErrListenerMalformed  warpnet.WarpError = "gossip: pubsub listener not initialized properly"
	ErrPubsubEmptyTopic   warpnet.WarpError = "gossip: topic name is empty"
	ErrPubsubNoPathFound  warpnet.WarpError = "gossip: user update message has no path"
	ErrPubsubEmptyMessage warpnet.WarpError = "gossip: empty message"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Gossip added in v0.5.8

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

func NewGossip added in v0.5.8

func NewGossip(
	ctx context.Context,
	ratings PeersRatings,
	handlers ...TopicHandler,
) *Gossip

func (*Gossip) Close added in v0.5.8

func (g *Gossip) Close() (err error)

func (*Gossip) IsGossipRunning added in v0.5.8

func (g *Gossip) IsGossipRunning() bool

func (*Gossip) NodeInfo added in v0.5.8

func (g *Gossip) NodeInfo() warpnet.NodeInfo

func (*Gossip) NotSubscribers added in v0.5.8

func (g *Gossip) NotSubscribers(topicName string) []warpnet.WarpAddrInfo

func (*Gossip) Publish added in v0.5.8

func (g *Gossip) Publish(msg event.Message, topics ...string) (err error)

func (*Gossip) PublishRaw added in v0.5.159

func (g *Gossip) PublishRaw(topicName string, data []byte) (err error)

func (*Gossip) Run added in v0.5.8

func (g *Gossip) Run(node GossipNodeConnector) (err error)

func (*Gossip) SelfPublish added in v0.5.8

func (g *Gossip) SelfPublish(data []byte) error

func (*Gossip) Subscribe added in v0.5.8

func (g *Gossip) Subscribe(handlers ...TopicHandler) (err error)

func (*Gossip) SubscribeRaw added in v0.5.159

func (g *Gossip) SubscribeRaw(topicName string, h func([]byte) error) (err error)

func (*Gossip) Subscribers added in v0.5.8

func (g *Gossip) Subscribers(topicName string) []warpnet.WarpAddrInfo

func (*Gossip) Unsubscribe added in v0.5.8

func (g *Gossip) Unsubscribe(topics ...string) (err error)

type GossipNodeConnector added in v0.3.112

type GossipNodeConnector interface {
	Node() warpnet.P2PNode
	NodeInfo() warpnet.NodeInfo
	SelfStream(from, to warpnet.WarpPeerID, path stream.WarpRoute, data any) (_ []byte, err error)
}

type PeersRatings added in v0.8.77

type PeersRatings interface {
	GossipScore(peerID warpnet.WarpPeerID) float64
}

PeersRatings answers what gossipsub should weigh a peer by, which is how a badly rated peer is read last and, at worst, not at all.

type TopicHandler added in v0.3.112

type TopicHandler struct {
	TopicName string
	Handler   topicHandler
}

func NewDiscoveryRelayTopicHandler added in v0.5.134

func NewDiscoveryRelayTopicHandler() TopicHandler

NewDiscoveryRelayTopicHandler acts only as relay

func NewDiscoveryTopicHandler added in v0.3.113

func NewDiscoveryTopicHandler(discHandler discovery.DiscoveryHandler) TopicHandler

func NewRelayTopicHandler added in v0.8.83

func NewRelayTopicHandler(topicName string) TopicHandler

Jump to

Keyboard shortcuts

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