server

package
v0.10.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultRecordsLimit          = 20
	DefaultStreamingRecordsLimit = 0
)
View Source
const FindProvidersPath = "/routing/v1/providers/{cid}"
View Source
const ProvidePath = "/routing/v1/providers/"

Variables

This section is empty.

Functions

func Handler

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

Types

type BitswapWriteProvideRequest

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

type ContentRouter

type ContentRouter interface {
	// FindProviders searches for peers who are able to provide a given key. Limit
	// indicates the maximum amount of results to return. 0 means unbounded.
	FindProviders(ctx context.Context, key cid.Cid, limit int) (iter.ResultIter[types.ProviderResponse], error)
	ProvideBitswap(ctx context.Context, req *BitswapWriteProvideRequest) (time.Duration, error)
	Provide(ctx context.Context, req *WriteProvideRequest) (types.ProviderResponse, error)
}

type FindProvidersAsyncResponse

type FindProvidersAsyncResponse struct {
	ProviderResponse types.ProviderResponse
	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 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 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

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

Jump to

Keyboard shortcuts

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