server

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: Apache-2.0, MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRecordsLimit          = 20
	DefaultStreamingRecordsLimit = 0
)
View Source
const (
	GetIPNSPath = "/routing/v1/ipns/{cid}"
)

Variables

This section is empty.

Functions

func Handler

func Handler(svc ContentRouter, opts ...Option) http.Handler

Types

type BitswapWriteProvideRequest deprecated

type BitswapWriteProvideRequest struct {
	Keys        []cid.Cid
	Timestamp   time.Time
	AdvisoryTTL time.Duration
	ID          peer.ID
	Addrs       []multiaddr.Multiaddr
}

Deprecated: protocol-agnostic provide is being worked on in IPIP-378:

type ContentRouter

type ContentRouter interface {
	// FindProviders searches for peers who are able to provide the given [cid.Cid].
	// Limit indicates the maximum amount of results to return; 0 means unbounded.
	FindProviders(ctx context.Context, cid cid.Cid, limit int) (iter.ResultIter[types.Record], error)

	// Deprecated: protocol-agnostic provide is being worked on in [IPIP-378]:
	//
	// [IPIP-378]: https://github.com/ipfs/specs/pull/378
	ProvideBitswap(ctx context.Context, req *BitswapWriteProvideRequest) (time.Duration, error)

	// FindPeers searches for peers who have the provided [peer.ID].
	// Limit indicates the maximum amount of results to return; 0 means unbounded.
	FindPeers(ctx context.Context, pid peer.ID, limit int) (iter.ResultIter[*types.PeerRecord], error)

	// GetIPNS searches for an [ipns.Record] for the given [ipns.Name].
	GetIPNS(ctx context.Context, name ipns.Name) (*ipns.Record, error)

	// PutIPNS stores the provided [ipns.Record] for the given [ipns.Name].
	// It is guaranteed that the record matches the provided name.
	PutIPNS(ctx context.Context, name ipns.Name, record *ipns.Record) error
}

type FindProvidersAsyncResponse

type FindProvidersAsyncResponse struct {
	ProviderResponse types.Record
	Error            error
}

type Option

type Option func(s *server)

func WithRecordsLimit

func WithRecordsLimit(limit int) Option

WithRecordsLimit sets a limit that will be passed to [ContentRouter.FindProviders] and [ContentRouter.FindPeers] for non-streaming requests (application/json). Default is DefaultRecordsLimit.

func WithStreamingRecordsLimit

func WithStreamingRecordsLimit(limit int) Option

WithStreamingRecordsLimit sets a limit that will be passed to [ContentRouter.FindProviders] and [ContentRouter.FindPeers] for streaming requests (application/x-ndjson). Default is DefaultStreamingRecordsLimit.

func WithStreamingResultsDisabled

func WithStreamingResultsDisabled() Option

WithStreamingResultsDisabled disables ndjson responses, so that the server only supports JSON responses.

type WriteProvideRequest deprecated

type WriteProvideRequest struct {
	Protocol string
	Schema   string
	Bytes    []byte
}

Deprecated: protocol-agnostic provide is being worked on in IPIP-378:

Jump to

Keyboard shortcuts

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