Documentation ¶
Index ¶
- Constants
- Variables
- type ClientOption
- type Option
- func WithHTTPListenAddrs(addrs ...string) Option
- func WithHandlerPath(urlPath string) Option
- func WithHeadTopic(topic string) Option
- func WithRequireTLS(require bool) Option
- func WithStartServer(start bool) Option
- func WithStreamHost(h host.Host) Option
- func WithTLSConfig(tlsConfig *tls.Config) Option
- type Publisher
- type Sync
- type Syncer
Constants ¶
const ( // IPNIPath is the path that the Publisher expects as the last port of the // HTTP request URL path. The sync client automatically adds this to the // request path. IPNIPath = "/ipni/v1/ad" // ProtocolID is the libp2p protocol ID used to identify the ipni-sync // protocol. With libp2phttp this protocol ID maps directly to a single // HTTP path, so the value of the protocol ID is the same as the IPNI path // for the ipni-sync protocol. ProtocolID = protocol.ID(IPNIPath) )
Variables ¶
var ErrNoHTTPServer = errors.New("publisher has libp2p server without HTTP")
Functions ¶
This section is empty.
Types ¶
type ClientOption ¶ added in v0.5.0
type ClientOption func(*clientConfig)
Option is a function that sets a value in a config.
func ClientAuthServerPeerID ¶ added in v0.5.0
func ClientAuthServerPeerID(require bool) ClientOption
ClientAuthServerPeerID tells the sync client that it must authenticate the server's peer ID.
func ClientHTTPRetry ¶ added in v0.5.0
func ClientHTTPRetry(retryMax int, waitMin, waitMax time.Duration) ClientOption
ClientHTTPRetry configures a retriable HTTP client. Setting retryMax to zero, the default, disables the retriable client.
func ClientHTTPTimeout ¶ added in v0.5.0
func ClientHTTPTimeout(to time.Duration) ClientOption
ClientHTTPTimeout specifies a time limit for HTTP requests made by the sync client. A value of zero means no timeout.
func ClientStreamHost ¶ added in v0.5.0
func ClientStreamHost(h host.Host) ClientOption
ClientStreamHost specifies an optional stream based libp2p host used by the sync client to do HTTP over libp2p streams.
type Option ¶
type Option func(*config) error
Option is a function that sets a value in a config.
func WithHTTPListenAddrs ¶ added in v0.5.0
WithHTTPListenAddrs sets the HTTP addresses to listen on. These are in addresses:port format and may be prefixed with "https://" or "http://" or to specify whether or not TLS is required. If there is no prefix, then one is assumed based on the value specified by WithRequireTLS.
Setting HTTP listen addresses is optional when a stream host is provided by the WithStreamHost option.
func WithHandlerPath ¶
WithHandlerPath sets the path used to handle requests to this publisher. This specifies the portion of the path before the implicit /ipni/v1/ad/ part of the path. Calling WithHandlerPath("/foo/bar") configures the publisher to handle HTTP requests on the path "/foo/bar/ipni/v1/ad/".
func WithHeadTopic ¶
WithHeadTopic sets the optional topic returned in a head query response. This is the topic on which advertisement are announced.
func WithRequireTLS ¶ added in v0.5.0
WithRequireTLS tells whether to allow the publisher to require https (true) or to serve non-secure http (false). Default is false, allowing non-secure HTTP.
func WithStartServer ¶ added in v0.5.0
WithStartServer, if true, starts an http server listening on the given address. an HTTP server. If this option is not specified, then no server is started and this will need to be done by the caller.
func WithStreamHost ¶ added in v0.5.0
WithStreamHost specifies an optional stream based libp2p host used to do HTTP over libp2p streams.
func WithTLSConfig ¶ added in v0.5.1
WithTLSConfig sets the TLS config for the HTTP server.
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
Publisher serves an advertisement chain over HTTP.
func NewPublisher ¶
NewPublisher creates a new ipni-sync publisher. Optionally, a libp2p stream host can be provided to serve HTTP over libp2p.
func (*Publisher) Addrs ¶
func (p *Publisher) Addrs() []multiaddr.Multiaddr
Addrs returns the slice of multiaddr addresses that the Publisher is listening on.
If the server is not started, WithStartServer(false), then this returns the multiaddr versions of the list of addresses given by WithHTTPListenAddrs and may not actually be a listening address.
func (*Publisher) Protocol ¶
Protocol returns the multiaddr protocol ID of the transport used by the publisher.
type Sync ¶
type Sync struct {
// contains filtered or unexported fields
}
Sync provides sync functionality for use with all http syncs.