client

package
v0.16.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0, MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ViewLatency = &view.View{
		Measure:     measureLatency,
		Aggregation: distMS,
		TagKeys:     []tag.Key{keyOperation, keyHost, keyStatusCode, keyError},
	}
	ViewLength = &view.View{
		Measure:     measureLength,
		Aggregation: distLength,
		TagKeys:     []tag.Key{keyOperation, keyHost},
	}

	OpenCensusViews = []*view.View{
		ViewLatency,
		ViewLength,
	}
)
View Source
var ImportPath = importPath()

ImportPath is the canonical import path that allows us to identify official client builds vs modified forks, and use that info in User-Agent header.

Functions

This section is empty.

Types

type Client added in v0.16.0

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

func New

func New(baseURL string, opts ...Option) (*Client, error)

New creates a content routing API client. The Provider and identity parameters are option. If they are nil, the client.ProvideBitswap method will not function.

func (*Client) FindPeers added in v0.16.0

func (c *Client) FindPeers(ctx context.Context, pid peer.ID) (peers iter.ResultIter[*types.PeerRecord], err error)

FindPeers searches for information for the given peer.ID.

func (*Client) FindProviders added in v0.16.0

func (c *Client) FindProviders(ctx context.Context, key cid.Cid) (providers iter.ResultIter[types.Record], err error)

FindProviders searches for providers that are able to provide the given cid.Cid. In a more generic way, it is also used as a mapping between CIDs and relevant metadata.

func (*Client) GetIPNS added in v0.16.0

func (c *Client) GetIPNS(ctx context.Context, name ipns.Name) (*ipns.Record, error)

GetIPNS tries to retrieve the ipns.Record for the given ipns.Name. The record is validated against the given name. If validation fails, an error is returned, but no record.

func (*Client) ProvideBitswap deprecated added in v0.16.0

func (c *Client) ProvideBitswap(ctx context.Context, keys []cid.Cid, ttl time.Duration) (time.Duration, error)

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

func (*Client) PutIPNS added in v0.16.0

func (c *Client) PutIPNS(ctx context.Context, name ipns.Name, record *ipns.Record) error

PutIPNS attempts at putting the given ipns.Record for the given ipns.Name.

type HTTPError

type HTTPError struct {
	StatusCode int
	Body       string
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

type Option

type Option func(*Client)

func WithHTTPClient

func WithHTTPClient(h httpClient) Option

func WithIdentity

func WithIdentity(identity crypto.PrivKey) Option

func WithProviderInfo

func WithProviderInfo(peerID peer.ID, addrs []multiaddr.Multiaddr) Option

func WithStreamResultsRequired

func WithStreamResultsRequired() Option

func WithUserAgent

func WithUserAgent(ua string) Option

type ResponseBodyLimitedTransport

type ResponseBodyLimitedTransport struct {
	http.RoundTripper
	LimitBytes int64
	UserAgent  string
}

func (*ResponseBodyLimitedTransport) RoundTrip

Jump to

Keyboard shortcuts

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