client

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0, MIT Imports: 30 Imported by: 11

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.14.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.14.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.14.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.14.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.14.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.14.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 added in v0.9.0

type Option func(*Client) error

func WithHTTPClient

func WithHTTPClient(h httpClient) Option

WithHTTPClient sets a custom HTTP Client to be used with Client.

func WithIdentity

func WithIdentity(identity crypto.PrivKey) Option

func WithProviderInfo

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

func WithStreamResultsRequired added in v0.9.0

func WithStreamResultsRequired() Option

func WithUserAgent

func WithUserAgent(ua string) Option

WithUserAgent sets a custom user agent to use with the HTTP Client. This modifies the underlying http.Client. Therefore, you should not use the same HTTP Client with multiple routing clients.

This only works if using a http.Client with a ResponseBodyLimitedTransport set as its transport. Otherwise, an error will be returned.

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