floodsub

package module
v0.0.0-...-8e452ac Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2017 License: MIT Imports: 16 Imported by: 0

README

go-floodsub

A flooding pubsub system.

Table of Contents

Install

go get github.com/libp2p/go-floodsub

Usage

TODO

Contribute

Contributions welcome. Please check out the issues.

Check out our contributing document for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS Code of Conduct.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © Jeromy Johnson

Documentation

Index

Constants

View Source
const (
	ID = protocol.ID("/floodsub/1.0.0")
)

Variables

This section is empty.

Functions

func WithValidator

func WithValidator(validate Validator) func(*Subscription) error

WithValidator is an option that can be supplied to Subscribe. The argument is a function that returns whether or not a given message should be propagated further.

func WithValidatorTimeout

func WithValidatorTimeout(timeout time.Duration) func(*Subscription) error

WithValidatorTimeout is an option that can be supplied to Subscribe. The argument is a duration after which long-running validators are canceled.

Types

type Message

type Message struct {
	*pb.Message
}

func (*Message) GetFrom

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

type Option

type Option func(*PubSub) error

func WithMaxConcurrency

func WithMaxConcurrency(n int) Option

type PubSub

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

func NewFloodSub

func NewFloodSub(ctx context.Context, h host.Host, opts ...Option) (*PubSub, error)

NewFloodSub returns a new FloodSub management object

func (*PubSub) GetTopics

func (p *PubSub) GetTopics() []string

GetTopics returns the topics this node is subscribed to

func (*PubSub) ListPeers

func (p *PubSub) ListPeers(topic string) []peer.ID

ListPeers returns a list of peers we are connected to.

func (*PubSub) Publish

func (p *PubSub) Publish(topic string, data []byte) error

Publish publishes data under the given topic

func (*PubSub) Subscribe

func (p *PubSub) Subscribe(topic string, opts ...SubOpt) (*Subscription, error)

Subscribe returns a new Subscription for the given topic

func (*PubSub) SubscribeByTopicDescriptor

func (p *PubSub) SubscribeByTopicDescriptor(td *pb.TopicDescriptor, opts ...SubOpt) (*Subscription, error)

SubscribeByTopicDescriptor lets you subscribe a topic using a pb.TopicDescriptor

type PubSubNotif

type PubSubNotif PubSub

func (*PubSubNotif) ClosedStream

func (p *PubSubNotif) ClosedStream(n inet.Network, s inet.Stream)

func (*PubSubNotif) Connected

func (p *PubSubNotif) Connected(n inet.Network, c inet.Conn)

func (*PubSubNotif) Disconnected

func (p *PubSubNotif) Disconnected(n inet.Network, c inet.Conn)

func (*PubSubNotif) Listen

func (p *PubSubNotif) Listen(n inet.Network, _ ma.Multiaddr)

func (*PubSubNotif) ListenClose

func (p *PubSubNotif) ListenClose(n inet.Network, _ ma.Multiaddr)

func (*PubSubNotif) OpenedStream

func (p *PubSubNotif) OpenedStream(n inet.Network, s inet.Stream)

type RPC

type RPC struct {
	pb.RPC
	// contains filtered or unexported fields
}

type SubOpt

type SubOpt func(*Subscription) error

type Subscription

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

func (*Subscription) Cancel

func (sub *Subscription) Cancel()

func (*Subscription) Next

func (sub *Subscription) Next(ctx context.Context) (*Message, error)

func (*Subscription) Topic

func (sub *Subscription) Topic() string

type Validator

type Validator func(context.Context, *Message) bool

Directories

Path Synopsis
Package floodsub_pb is a generated protocol buffer package.
Package floodsub_pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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