Documentation
¶
Index ¶
- Constants
- func Cache(ctx context.Context, log logging.EventLogger, ...) error
- type MockProviderIndex
- func (_mock *MockProviderIndex) Cache(ctx context.Context, provider peer.AddrInfo, contextID string, ...) error
- func (_m *MockProviderIndex) EXPECT() *MockProviderIndex_Expecter
- func (_mock *MockProviderIndex) Find(context1 context.Context, queryKey QueryKey) ([]model.ProviderResult, error)
- func (_mock *MockProviderIndex) Publish(ctx context.Context, provider peer.AddrInfo, contextID string, ...) error
- type MockProviderIndex_Cache_Call
- func (_c *MockProviderIndex_Cache_Call) Return(err error) *MockProviderIndex_Cache_Call
- func (_c *MockProviderIndex_Cache_Call) Run(run func(ctx context.Context, provider peer.AddrInfo, contextID string, ...)) *MockProviderIndex_Cache_Call
- func (_c *MockProviderIndex_Cache_Call) RunAndReturn(...) *MockProviderIndex_Cache_Call
- type MockProviderIndex_Expecter
- func (_e *MockProviderIndex_Expecter) Cache(ctx interface{}, provider interface{}, contextID interface{}, ...) *MockProviderIndex_Cache_Call
- func (_e *MockProviderIndex_Expecter) Find(context1 interface{}, queryKey interface{}) *MockProviderIndex_Find_Call
- func (_e *MockProviderIndex_Expecter) Publish(ctx interface{}, provider interface{}, contextID interface{}, ...) *MockProviderIndex_Publish_Call
- type MockProviderIndex_Find_Call
- func (_c *MockProviderIndex_Find_Call) Return(providerResults []model.ProviderResult, err error) *MockProviderIndex_Find_Call
- func (_c *MockProviderIndex_Find_Call) Run(run func(context1 context.Context, queryKey QueryKey)) *MockProviderIndex_Find_Call
- func (_c *MockProviderIndex_Find_Call) RunAndReturn(...) *MockProviderIndex_Find_Call
- type MockProviderIndex_Publish_Call
- func (_c *MockProviderIndex_Publish_Call) Return(err error) *MockProviderIndex_Publish_Call
- func (_c *MockProviderIndex_Publish_Call) Run(run func(ctx context.Context, provider peer.AddrInfo, contextID string, ...)) *MockProviderIndex_Publish_Call
- func (_c *MockProviderIndex_Publish_Call) RunAndReturn(...) *MockProviderIndex_Publish_Call
- type Option
- type ProviderIndex
- type ProviderIndexService
- func (pi *ProviderIndexService) Cache(ctx context.Context, provider peer.AddrInfo, contextID string, ...) error
- func (pi *ProviderIndexService) Find(ctx context.Context, qk QueryKey) ([]model.ProviderResult, error)
- func (pi *ProviderIndexService) Publish(ctx context.Context, provider peer.AddrInfo, contextID string, ...) error
- type QueryKey
Constants ¶
const ( // MaxBatchSize is the maximum number of items that'll be added to a batch. MaxBatchSize = 10_000 // IPNITimeout is the duration after which an IPNI query will be cancelled. // It is set relatively high, since the IPNI client is tiered, with individual // timeouts set at 1.5s. IPNITimeout = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MockProviderIndex ¶ added in v0.10.4
MockProviderIndex is an autogenerated mock type for the ProviderIndex type
func NewMockProviderIndex ¶ added in v0.10.4
func NewMockProviderIndex(t interface {
mock.TestingT
Cleanup(func())
}) *MockProviderIndex
NewMockProviderIndex creates a new instance of MockProviderIndex. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockProviderIndex) Cache ¶ added in v0.10.4
func (_mock *MockProviderIndex) Cache(ctx context.Context, provider peer.AddrInfo, contextID string, digests iter.Seq[multihash.Multihash], meta metadata.Metadata) error
Cache provides a mock function for the type MockProviderIndex
func (*MockProviderIndex) EXPECT ¶ added in v0.10.4
func (_m *MockProviderIndex) EXPECT() *MockProviderIndex_Expecter
func (*MockProviderIndex) Find ¶ added in v0.10.4
func (_mock *MockProviderIndex) Find(context1 context.Context, queryKey QueryKey) ([]model.ProviderResult, error)
Find provides a mock function for the type MockProviderIndex
type MockProviderIndex_Cache_Call ¶ added in v0.10.4
MockProviderIndex_Cache_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Cache'
func (*MockProviderIndex_Cache_Call) Return ¶ added in v0.10.4
func (_c *MockProviderIndex_Cache_Call) Return(err error) *MockProviderIndex_Cache_Call
type MockProviderIndex_Expecter ¶ added in v0.10.4
type MockProviderIndex_Expecter struct {
// contains filtered or unexported fields
}
func (*MockProviderIndex_Expecter) Cache ¶ added in v0.10.4
func (_e *MockProviderIndex_Expecter) Cache(ctx interface{}, provider interface{}, contextID interface{}, digests interface{}, meta interface{}) *MockProviderIndex_Cache_Call
Cache is a helper method to define mock.On call
- ctx context.Context
- provider peer.AddrInfo
- contextID string
- digests iter.Seq[multihash.Multihash]
- meta metadata.Metadata
func (*MockProviderIndex_Expecter) Find ¶ added in v0.10.4
func (_e *MockProviderIndex_Expecter) Find(context1 interface{}, queryKey interface{}) *MockProviderIndex_Find_Call
Find is a helper method to define mock.On call
- context1 context.Context
- queryKey QueryKey
func (*MockProviderIndex_Expecter) Publish ¶ added in v0.10.4
func (_e *MockProviderIndex_Expecter) Publish(ctx interface{}, provider interface{}, contextID interface{}, digests interface{}, meta interface{}) *MockProviderIndex_Publish_Call
Publish is a helper method to define mock.On call
- ctx context.Context
- provider peer.AddrInfo
- contextID string
- digests iter.Seq[multihash.Multihash]
- meta metadata.Metadata
type MockProviderIndex_Find_Call ¶ added in v0.10.4
MockProviderIndex_Find_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Find'
func (*MockProviderIndex_Find_Call) Return ¶ added in v0.10.4
func (_c *MockProviderIndex_Find_Call) Return(providerResults []model.ProviderResult, err error) *MockProviderIndex_Find_Call
func (*MockProviderIndex_Find_Call) Run ¶ added in v0.10.4
func (_c *MockProviderIndex_Find_Call) Run(run func(context1 context.Context, queryKey QueryKey)) *MockProviderIndex_Find_Call
func (*MockProviderIndex_Find_Call) RunAndReturn ¶ added in v0.10.4
func (_c *MockProviderIndex_Find_Call) RunAndReturn(run func(context1 context.Context, queryKey QueryKey) ([]model.ProviderResult, error)) *MockProviderIndex_Find_Call
type MockProviderIndex_Publish_Call ¶ added in v0.10.4
MockProviderIndex_Publish_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Publish'
func (*MockProviderIndex_Publish_Call) Return ¶ added in v0.10.4
func (_c *MockProviderIndex_Publish_Call) Return(err error) *MockProviderIndex_Publish_Call
type Option ¶ added in v0.10.4
type Option func(conf *config)
Option configures an ProviderIndex.
func WithClock ¶ added in v0.10.4
WithClock configures the provider index with a mockable clock for testing.
func WithLogger ¶ added in v0.10.4
func WithLogger(log logging.EventLogger) Option
WithLogger configures the service to use the passed logger instead of the default logger.
type ProviderIndex ¶
type ProviderIndex interface {
// Find should do the following
// 1. Read from the IPNI Storage cache to get a list of providers
// a. If there is no record in cache, query IPNI, filter out any non-content claims metadata, and store
// the resulting records in the cache
// b. the are no records in the cache or IPNI, it can attempt to read from legacy systems -- Dynamo tables & content claims storage, synthetically constructing provider results
// 2. With returned provider results, filter additionally for claim type. If space dids are set, calculate an encodedcontextid's by hashing space DID and Hash, and filter for a matching context id
// Future TODO: kick off a conversion task to update the recrds
Find(context.Context, QueryKey) ([]model.ProviderResult, error)
// Cache writes entries to the cache but does not publish/announce an
// advertisement for them. Entries expire after a pre-determined time.
Cache(ctx context.Context, provider peer.AddrInfo, contextID string, digests iter.Seq[multihash.Multihash], meta meta.Metadata) error
// Publish should do the following:
// 1. Write the entries to the cache with no expiration until publishing is complete
// 2. Generate an advertisement for the advertised hashes and publish/announce it
Publish(ctx context.Context, provider peer.AddrInfo, contextID string, digests iter.Seq[multihash.Multihash], meta meta.Metadata) error
}
ProviderIndex is a read/write interface to a local cache of providers that falls back to legacy systems and IPNI
type ProviderIndexService ¶ added in v0.10.4
type ProviderIndexService struct {
// contains filtered or unexported fields
}
ProviderIndexService is a read/write interface to a local cache of providers that falls back to IPNI
func New ¶ added in v0.10.4
func New(providerStore types.ProviderStore, noProviderStore types.NoProviderStore, findClient ipnifind.Finder, asyncPublisher publisher.AsyncPublisher, legacyClaims legacy.ClaimsFinder, options ...Option) *ProviderIndexService
func (*ProviderIndexService) Find ¶ added in v0.10.4
func (pi *ProviderIndexService) Find(ctx context.Context, qk QueryKey) ([]model.ProviderResult, error)
Find should do the following
- Read from the IPNI Storage cache to get a list of providers a. if there are no records in the cache, query IPNI, filtering out any non-content claims metadata b. if no records are found in IPNI, attempt to read claims from legacy systems -- Dynamo tables & content claims storage, synthetically constructing provider results c. finally, store the resulting records in the cache
- With returned provider results, filter additionally for claim type. If space dids are set, calculate an encodedcontextid's by hashing space DID and Hash, and filter for a matching context id Future TODO: kick off a conversion task to update the records
func (*ProviderIndexService) Publish ¶ added in v0.10.4
func (pi *ProviderIndexService) Publish(ctx context.Context, provider peer.AddrInfo, contextID string, digests iter.Seq[mh.Multihash], meta meta.Metadata) error
Publish should do the following: 1. Write the entries to the cache with no expiration until publishing is complete 2. Generate an advertisement for the advertised hashes and publish/announce it