Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) FindPeers(ctx context.Context, pid peer.ID) (peers iter.ResultIter[*types.PeerRecord], err error)
- func (c *Client) FindProviders(ctx context.Context, key cid.Cid) (providers iter.ResultIter[types.Record], err error)
- func (c *Client) GetIPNS(ctx context.Context, name ipns.Name) (*ipns.Record, error)
- func (c *Client) ProvideBitswap(ctx context.Context, keys []cid.Cid, ttl time.Duration) (time.Duration, error)deprecated
- func (c *Client) PutIPNS(ctx context.Context, name ipns.Name, record *ipns.Record) error
- type HTTPError
- type Option
- func WithAddrFilter(addrFilter []string) Option
- func WithDisabledLocalFiltering(val bool) Option
- func WithHTTPClient(h httpClient) Option
- func WithIdentity(identity crypto.PrivKey) Option
- func WithProtocolFilter(protocolFilter []string) Option
- func WithProviderInfo(peerID peer.ID, addrs []multiaddr.Multiaddr) Option
- func WithStreamResultsRequired() Option
- func WithUserAgent(ua string) Option
- type ResponseBodyLimitedTransport
Constants ¶
This section is empty.
Variables ¶
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, } )
var (
DefaultProtocolFilter = []string{"unknown", "transport-bitswap"} // IPIP-484
)
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.24.3
type Client struct {
// contains filtered or unexported fields
}
func New ¶
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.24.3
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.24.3
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.24.3
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.
type Option ¶
func WithAddrFilter ¶ added in v0.24.3
WithAddrFilter adds an address filter to the client. The address filter is added to the request URL. The addresses are ordered alphabetically for cache key (url) consistency
func WithDisabledLocalFiltering ¶ added in v0.24.3
WithDisabledLocalFiltering disables local filtering of the results. This should be used for delegated routing servers that already implement filtering
func WithHTTPClient ¶
func WithHTTPClient(h httpClient) Option
WithHTTPClient sets a custom HTTP Client to be used with Client.
func WithIdentity ¶
func WithProtocolFilter ¶ added in v0.24.3
WithProtocolFilter adds a protocol filter to the client. The protocol filter is added to the request URL. The protocols are ordered alphabetically for cache key (url) consistency
func WithProviderInfo ¶
func WithStreamResultsRequired ¶
func WithStreamResultsRequired() Option
func WithUserAgent ¶
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 }