namesys

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: MIT Imports: 21 Imported by: 24

README

go-libp2p-pubsub-router

GoDoc Coverage Status Build Status Discourse posts

A libp2p router that uses pubsub.

We currently only use this for IPNS over PubSub.

Documenation

See https://godoc.org/github.com/libp2p/go-libp2p-pubsub-router.

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the libp2p Code of Conduct.

Want to hack on libp2p?

License

MIT


The last gx published version of this module was: 0.5.18: QmaHVH3EqQD6DsE1yPgwfCThvFCwfkJ396uyrRSo3Ku1kH

Documentation

Index

Constants

View Source
const FetchProtoID = protocol.ID("/libp2p/fetch/0.0.1")

Variables

This section is empty.

Functions

func KeyToTopic

func KeyToTopic(key string) string

KeyToTopic converts a binary record key to a pubsub topic key.

Types

type Option added in v0.2.0

type Option func(*PubsubValueStore) error

Option is a function that configures a PubsubValueStore during initialization

func WithDatastore added in v0.5.0

func WithDatastore(datastore ds.Datastore) Option

WithDatastore returns an option that overrides the default datastore.

func WithRebroadcastInitialDelay added in v0.2.0

func WithRebroadcastInitialDelay(duration time.Duration) Option

func WithRebroadcastInterval added in v0.2.0

func WithRebroadcastInterval(duration time.Duration) Option

type Pubsub added in v0.2.1

type Pubsub interface {
	RegisterTopicValidator(topic string, validator interface{}, opts ...pubsub.ValidatorOpt) error
	Join(topic string, opts ...pubsub.TopicOpt) (*pubsub.Topic, error)
}

Pubsub is the minimal subset of the pubsub interface required by the pubsub value store. This way, users can wrap the underlying pubsub implementation without re-exporting/implementing the entire interface.

type PubsubValueStore

type PubsubValueStore struct {
	Validator record.Validator
	// contains filtered or unexported fields
}

func NewPubsubValueStore

func NewPubsubValueStore(ctx context.Context, host host.Host, ps Pubsub, validator record.Validator, opts ...Option) (*PubsubValueStore, error)

NewPubsubValueStore constructs a new ValueStore that gets and receives records through pubsub.

func (*PubsubValueStore) Cancel

func (p *PubsubValueStore) Cancel(name string) (bool, error)

Cancel cancels a topic subscription; returns true if an active subscription was canceled

func (*PubsubValueStore) GetSubscriptions

func (p *PubsubValueStore) GetSubscriptions() []string

GetSubscriptions retrieves a list of active topic subscriptions

func (*PubsubValueStore) GetValue

func (p *PubsubValueStore) GetValue(ctx context.Context, key string, opts ...routing.Option) ([]byte, error)

func (*PubsubValueStore) PutValue

func (p *PubsubValueStore) PutValue(ctx context.Context, key string, value []byte, opts ...routing.Option) error

PutValue publishes a record through pubsub

func (*PubsubValueStore) SearchValue

func (p *PubsubValueStore) SearchValue(ctx context.Context, key string, opts ...routing.Option) (<-chan []byte, error)

func (*PubsubValueStore) Subscribe

func (p *PubsubValueStore) Subscribe(key string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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