pubsub

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeMessage

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

FakeMessage is a simple pubsub message

func (*FakeMessage) GetData

func (m *FakeMessage) GetData() []byte

GetData returns the message's payload

func (*FakeMessage) GetFrom

func (m *FakeMessage) GetFrom() peer.ID

GetFrom returns the message's sender ID

type FakeSubscription

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

FakeSubscription is a fake pubsub subscription.

func NewFakeSubscription

func NewFakeSubscription(topic string, bufSize int) *FakeSubscription

NewFakeSubscription builds a new fake subscription to a topic.

func (*FakeSubscription) AwaitCancellation

func (s *FakeSubscription) AwaitCancellation()

AwaitCancellation waits for the subscription to be canceled by the subscriber.

func (*FakeSubscription) Cancel

func (s *FakeSubscription) Cancel()

Cancel cancels this subscription, after which no subsequently posted messages will be received.

func (*FakeSubscription) Fail

func (s *FakeSubscription) Fail(err error)

Fail causes subsequent reads from this subscription to fail.

func (*FakeSubscription) Next

func (s *FakeSubscription) Next(ctx context.Context) (Message, error)

Next returns the next messages from this subscription.

func (*FakeSubscription) Post

func (s *FakeSubscription) Post(msg Message)

Post posts a new message to this subscription.

func (*FakeSubscription) Topic

func (s *FakeSubscription) Topic() string

Topic returns this subscription's topic.

type Message

type Message interface {
	GetFrom() 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 Publisher

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

Publisher publishes to pubsub topics

func NewPublisher

func NewPublisher(sub *pubsub.PubSub) *Publisher

NewPublisher builds a new publisher

func (*Publisher) Publish

func (s *Publisher) Publish(topic string, data []byte) error

Publish publishes to a pubsub topic

type Subscriber

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

Subscriber subscribes to pubsub topics

func NewSubscriber

func NewSubscriber(sub *libp2p.PubSub) *Subscriber

NewSubscriber builds a new subscriber

func (*Subscriber) Subscribe

func (s *Subscriber) Subscribe(topic string) (Subscription, error)

Subscribe subscribes to a pubsub topic

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.

Jump to

Keyboard shortcuts

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