floodsub

package module
v0.0.0-...-f2454ee Latest Latest
Warning

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

Go to latest
Published: May 21, 2018 License: MIT Imports: 17 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 (
	FloodSubID = protocol.ID("/floodsub/1.0.0")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FloodSubRouter

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

func (*FloodSubRouter) AddPeer

func (fs *FloodSubRouter) AddPeer(peer.ID, protocol.ID)

func (*FloodSubRouter) Attach

func (fs *FloodSubRouter) Attach(p *PubSub)

func (*FloodSubRouter) HandleRPC

func (fs *FloodSubRouter) HandleRPC(rpc *RPC)

func (*FloodSubRouter) Protocols

func (fs *FloodSubRouter) Protocols() []protocol.ID

func (*FloodSubRouter) Publish

func (fs *FloodSubRouter) Publish(from peer.ID, msg *pb.Message)

func (*FloodSubRouter) RemovePeer

func (fs *FloodSubRouter) RemovePeer(peer.ID)

type Message

type Message struct {
	*pb.Message
}

func (*Message) GetFrom

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

type Option

type Option func(*PubSub) error

func WithValidateThrottle

func WithValidateThrottle(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 PubSub object using the FloodSubRouter

func NewPubSub

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

NewFloodSub returns a new PubSub 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) RegisterTopicValidator

func (p *PubSub) RegisterTopicValidator(topic string, val Validator, opts ...ValidatorOpt) error

RegisterTopicValidator registers a validator for 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

func (*PubSub) UnregisterTopicValidator

func (p *PubSub) UnregisterTopicValidator(topic string) error

UnregisterTopicValidator removes a validator from a topic returns an error if there was no validator registered with the topic

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 PubSubRouter

type PubSubRouter interface {
	Protocols() []protocol.ID
	Attach(*PubSub)
	AddPeer(peer.ID, protocol.ID)
	RemovePeer(peer.ID)
	HandleRPC(*RPC)
	Publish(peer.ID, *pb.Message)
}

PubSubRouter is the message router component of PubSub

type RPC

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

type SubOpt

type SubOpt func(sub *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

Validator is a function that validates a message

type ValidatorOpt

type ValidatorOpt func(addVal *addValReq) error

ValidatorOpt is an option for RegisterTopicValidator

func WithValidatorConcurrency

func WithValidatorConcurrency(n int) ValidatorOpt

WithValidatorConcurrency is an option that sets topic validator throttle

func WithValidatorTimeout

func WithValidatorTimeout(timeout time.Duration) ValidatorOpt

WithValidatorTimeout is an option that sets the topic validator timeout

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
⌂ 换网址