pubsub

package
v1.4.2-beta3 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message interface {
	GetSource() peer.ID
	GetSender() peer.ID
	GetData() []byte
}

Message defines the common interface for go-filecoin message consumers. It's a subset of the go-libp2p-pubsub/pubsub.go Message type.

type Subscription

type Subscription interface {
	// Topic returns this subscription's topic name
	Topic() string
	// Next returns the next message from this subscription
	Next(ctx context.Context) (Message, error)
	// Cancel cancels this subscription
	Cancel()
}

Subscription is a handle to a pubsub subscription. This matches part of the interface to a libp2p.pubsub.Subscription.

type Topic added in v1.4.0

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

Topic publishes and subscribes to a libp2p pubsub topic

func NewTopic added in v1.4.0

func NewTopic(topic *libp2p.Topic) *Topic

NewTopic builds a new topic.

func (*Topic) Publish added in v1.4.0

func (t *Topic) Publish(ctx context.Context, data []byte) error

Publish publishes to a pubsub topic. It blocks until there is at least one peer on the mesh that can receive the publish.

func (*Topic) Subscribe added in v1.4.0

func (t *Topic) Subscribe() (Subscription, error)

Subscribe subscribes to a pubsub topic

Jump to

Keyboard shortcuts

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