pubsub

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

pubsub a publish subscribe client for IPFS PubSub

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMessageEvent

func NewMessageEvent(topic string, content []byte) events.Event

Creates a new Message event

Types

type Interface

type Interface interface {
	// Subscribe Subscribes to a topic
	Subscribe(ctx context.Context, topic string) (Subscription, error)

	// Unsubscribe Unsubscribe from a topic
	Unsubscribe(topic string) error

	// Close Unsubscribe from all topics
	Close() error

	// Publish Posts a new message on a topic
	Publish(ctx context.Context, topic string, message []byte) error
}

func NewPubSub

func NewPubSub(is coreapi.CoreAPI, id peer.ID, opts *Options) (Interface, error)

NewPubSub Creates a new pubsub client

type MessageEvent

type MessageEvent struct {
	Topic   string
	Content []byte
}

MessageEvent Indicates a new message posted on a pubsub topic

type Options added in v1.4.0

type Options struct {
	Logger *zap.Logger
}

type Subscription

type Subscription interface {
	events.EmitterInterface
	io.Closer
}

Subscription is a pub sub subscription to a topic

func NewSubscription

func NewSubscription(ctx context.Context, ipfs coreapi.CoreAPI, topic string, cancel context.CancelFunc, opts *Options) (Subscription, error)

NewSubscription Creates a new pub sub subscription

Directories

Path Synopsis
oneonone is a pubsub channel for communication between two peers
oneonone is a pubsub channel for communication between two peers
peermonitor is a package for watching peers on a pub sub channel
peermonitor is a package for watching peers on a pub sub channel

Jump to

Keyboard shortcuts

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