httpsync

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: Apache-2.0, MIT Imports: 26 Imported by: 0

Documentation

Overview

Package httpsync is a fork of github.com/ipni/go-libipni/dagsync/httpsync with some modifications to make it work for the current Frisbii usecase. It needs to be reconciled back into that package and removed from here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SignedHeadSchema

func SignedHeadSchema() schema.Type

Types

type Option

type Option func(*config) error

Option is a function that sets a value in a config.

func WithAnnounceSenders

func WithAnnounceSenders(senders ...announce.Sender) Option

WithAnnounceSenders sets announce.Senders to use for sending announcements.

func WithExtraData

func WithExtraData(data []byte) Option

WithExtraData sets the extra data to include in the pubsub message.

type Publisher

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

Publisher is an HTTP publisher that announces the head of an advertisement chain to a set of configured senders.

func NewPublisher

func NewPublisher(address string, lsys ipld.LinkSystem, privKey ic.PrivKey, options ...Option) (*Publisher, error)

NewPublisher creates a new http publisher, listening on the specified address.

func NewPublisherForListener

func NewPublisherForListener(listener net.Listener, handlerPath string, lsys ipld.LinkSystem, privKey ic.PrivKey, options ...Option) (*Publisher, error)

NewPublisherForListener creates a new http publisher for an existing listener. When providing an existing listener, running the HTTP server is the caller's responsibility. ServeHTTP on the returned Publisher can be used to handle requests. handlerPath is the path to handle requests on, e.g. "ipni" for `/ipni/...` requests.

DEPRECATED: use NewPublisherWithoutServer(listener.Addr(), ...)

func NewPublisherWithoutServer

func NewPublisherWithoutServer(address string, handlerPath string, lsys ipld.LinkSystem, privKey ic.PrivKey, options ...Option) (*Publisher, error)

NewPublisherWithoutServer creates a new http publisher for an existing network address. When providing an existing network address, running the HTTP server is the caller's responsibility. ServeHTTP on the returned Publisher can be used to handle requests. handlerPath is the path to handle requests on, e.g. "ipni" for `/ipni/...` requests.

func (*Publisher) Addrs

func (p *Publisher) Addrs() []multiaddr.Multiaddr

Addrs returns the addresses, as []multiaddress, that the Publisher is listening on.

func (*Publisher) AnnounceHead

func (p *Publisher) AnnounceHead(ctx context.Context) error

AnnounceHead announces the head of the advertisement chain to the configured senders.

func (*Publisher) AnnounceHeadWithAddrs

func (p *Publisher) AnnounceHeadWithAddrs(ctx context.Context, addrs []multiaddr.Multiaddr) error

AnnounceHeadWithAddrs announces the head of the advertisement chain to the configured senders, with the provided addresses.

func (*Publisher) Close

func (p *Publisher) Close() error

Close closes the Publisher and all of its senders.

func (*Publisher) ID

func (p *Publisher) ID() peer.ID

ID returns the p2p peer ID of the Publisher.

func (*Publisher) Protocol

func (p *Publisher) Protocol() int

Protocol returns the multihash protocol ID of the transport used by the publisher.

func (*Publisher) ServeHTTP

func (p *Publisher) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface.

func (*Publisher) SetRoot

func (p *Publisher) SetRoot(_ context.Context, c cid.Cid) error

SetRoot sets the head of the advertisement chain.

func (*Publisher) UpdateRoot

func (p *Publisher) UpdateRoot(ctx context.Context, c cid.Cid) error

UpdateRoot updates the head of the advertisement chain and announces it to the configured senders.

func (*Publisher) UpdateRootWithAddrs

func (p *Publisher) UpdateRootWithAddrs(ctx context.Context, c cid.Cid, addrs []multiaddr.Multiaddr) error

UpdateRootWithAddrs updates the head of the advertisement chain and announces it to the configured senders, with the provided addresses.

Jump to

Keyboard shortcuts

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