publisher

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: Apache-2.0, MIT Imports: 20 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrContextIDNotFound signals that no item is associated to the given
	// context ID.
	ErrContextIDNotFound = errors.New("context ID not found")

	// ErrAlreadyAdvertised signals that an advertisement for identical content
	// was already published.
	ErrAlreadyAdvertised = errors.New("advertisement already published")
)

Functions

func GenerateAd added in v0.6.0

func GenerateAd(ctx context.Context, publisherStore store.PublisherStore, peer peer.ID, addrs []multiaddr.Multiaddr, contextID []byte, md metadata.Metadata, isRm bool, mhs iter.Seq[mh.Multihash]) (schema.Advertisement, error)

GenerateAd generates an advertisement for the given parameters.

Types

type AdvertisementPublisher added in v0.6.0

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

func NewAdvertisementPublisher added in v0.6.0

func NewAdvertisementPublisher(id crypto.PrivKey, store store.PublisherStore, opts ...Option) (*AdvertisementPublisher, error)

func (*AdvertisementPublisher) AddToBatch added in v0.6.0

func (p *AdvertisementPublisher) AddToBatch(adv schema.Advertisement) error

func (*AdvertisementPublisher) Commit added in v0.6.0

type AsyncPublisher added in v0.3.1

type AsyncPublisher interface {
	// Publish creates, signs and publishes an advert but does so asynchronously, so no advert CID is returned.
	Publish(ctx context.Context, provider peer.AddrInfo, contextID string, digests iter.Seq[mh.Multihash], meta metadata.Metadata) error
}

func AsyncFrom added in v0.3.1

func AsyncFrom(p Publisher) AsyncPublisher

type IPNIPublisher

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

func New

func New(id crypto.PrivKey, store store.PublisherStore, opts ...Option) (*IPNIPublisher, error)

New creates a new IPNI publisher. IPNIPublisher is not safe for concurrent use. There is the risk of losing advertisements if Publish is called from concurrent goroutines. If you will be publishing from multiple goroutines concurrently, a synchronization mechanism (such as sync.Mutex) must be used to ensure that Publish is called serially.

func (*IPNIPublisher) Publish

func (p *IPNIPublisher) Publish(ctx context.Context, providerInfo peer.AddrInfo, contextID string, digests iter.Seq[mh.Multihash], meta metadata.Metadata) (ipld.Link, error)

Publish creates a new advertisement from the latest head, signs it, and publishes it. Publish is not safe for concurrent use and advertisements may be lost if called concurrently. A mutex or any other synchronization mechanism must be used around Publish if it will be called from concurrent goroutines.

type Option

type Option func(cfg *options) error

Option is an option configuring a publisher.

func WithAnnounceAddrs

func WithAnnounceAddrs(addrs ...string) Option

WithAnnounceAddrs configures the multiaddrs that are put into announce messages to tell indexers the addresses to fetch advertisements from.

func WithDirectAnnounce

func WithDirectAnnounce(announceURLs ...string) Option

WithDirectAnnounce sets indexer URLs to send direct HTTP announcements to.

func WithTopic

func WithTopic(topic string) Option

type Publisher

type Publisher interface {
	// Publish creates, signs and publishes an advert. It then announces the new
	// advert to other indexers.
	Publish(ctx context.Context, provider peer.AddrInfo, contextID string, digests iter.Seq[mh.Multihash], meta metadata.Metadata) (ipld.Link, error)
}

Jump to

Keyboard shortcuts

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