publisher

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: Apache-2.0, MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const PandoTopic = "/pando/v0.0.1"

PandoTopic is the gossipsub topic on which the metadata announcements are published.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*options) error

Option represents a configurable parameter in a publisher.

func WithBootstrapPeers

func WithBootstrapPeers(b ...peer.AddrInfo) Option

WithBootstrapPeers optionally sets the list of peers to which to remain connected. If unset, no bootstrapping will be performed.

See: bootstrap.DefaultBootstrapConfig

func WithExternalAddrs added in v0.0.47

func WithExternalAddrs(addrs []multiaddr.Multiaddr) Option

WithExternalAddrs sets the addresses to include in published legs messages as the address on which the hsot can be reached. Defaults to host listen addresses.

func WithHost

func WithHost(h host.Host) Option

WithHost sets the host on which the publisher is exposed. If unset, a default libp2p host is created with random identity and listen addrtesses.

See: libp2p.New.

func WithTopic

func WithTopic(topic string) Option

WithTopic sets the gossipsub topic to which announcements are made. Defaults to `/pando/v0.0.1` if unset.

type PandoPublisher

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

func (*PandoPublisher) Publish

func (p *PandoPublisher) Publish(ctx context.Context, c cid.Cid) error

Publish wraps the given CID into a Pando metadata instance and announces the CID of resulting metadata.

The metadata produced, simply uses the byte value of the given CID as payload of the Pando metadata schema. See: https://github.com/kenlabs/pando

Note that the given CID must be preset in the store passed to the publisher at initialization.

func (*PandoPublisher) Shutdown

func (p *PandoPublisher) Shutdown(_ context.Context) error

Shutdown shuts down this publisher. Once shut down, this publisher should be discarded and can no longer be used.

func (*PandoPublisher) Start

func (p *PandoPublisher) Start(ctx context.Context) (err error)

type Publisher

type Publisher interface {
	Start(context.Context) error
	Publish(context.Context, cid.Cid) error
	Shutdown(context.Context) error
}

func NewPandoPublisher

func NewPandoPublisher(ds datastore.Batching, store storage.ReadableStorage, o ...Option) (Publisher, error)

NewPandoPublisher instantiates a new publisher that publishes announcements compatible with the Pando service by wrapping the CID of the original data within a Pando's metadata instance.

A user may call PandoPublisher.Publish with the CID of original data to produce one such announcement. Note that any CID passed to PandoPublisher.Publish must be available to read via the given store. See: PandoPublisher.Publish.

This publisher must be started via PandoPublisher.Start prior to use and shut down when no longer needed via PandoPublisher.Shutdown.

The ds datastore is used internally by the publisher and is not closed upon shutdown.

Jump to

Keyboard shortcuts

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