providerindex

package
v1.13.4 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: Apache-2.0, MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
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

func Cache added in v0.10.4

func Cache(ctx context.Context, log logging.EventLogger, providerStore types.ProviderStore, provider peer.AddrInfo, contextID string, digests iter.Seq[mh.Multihash], meta meta.Metadata, expire bool) error

Types

type MockProviderIndex added in v0.10.4

type MockProviderIndex struct {
	mock.Mock
}

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 (*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

func (*MockProviderIndex) Publish added in v0.10.4

func (_mock *MockProviderIndex) Publish(ctx context.Context, provider peer.AddrInfo, contextID string, digests iter.Seq[multihash.Multihash], meta metadata.Metadata) error

Publish provides a mock function for the type MockProviderIndex

type MockProviderIndex_Cache_Call added in v0.10.4

type MockProviderIndex_Cache_Call struct {
	*mock.Call
}

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 (*MockProviderIndex_Cache_Call) Run added in v0.10.4

func (*MockProviderIndex_Cache_Call) RunAndReturn added in v0.10.4

func (_c *MockProviderIndex_Cache_Call) RunAndReturn(run func(ctx context.Context, provider peer.AddrInfo, contextID string, digests iter.Seq[multihash.Multihash], meta metadata.Metadata) 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

type MockProviderIndex_Find_Call struct {
	*mock.Call
}

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 (*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

type MockProviderIndex_Publish_Call struct {
	*mock.Call
}

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 (*MockProviderIndex_Publish_Call) Run added in v0.10.4

func (*MockProviderIndex_Publish_Call) RunAndReturn added in v0.10.4

func (_c *MockProviderIndex_Publish_Call) RunAndReturn(run func(ctx context.Context, provider peer.AddrInfo, contextID string, digests iter.Seq[multihash.Multihash], meta metadata.Metadata) 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

func WithClock(clock clock.Clock) Option

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) Cache added in v0.10.4

func (pi *ProviderIndexService) Cache(ctx context.Context, provider peer.AddrInfo, contextID string, digests iter.Seq[mh.Multihash], meta meta.Metadata) error

func (*ProviderIndexService) Find added in v0.10.4

Find should do the following

  1. 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
  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 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

type QueryKey

type QueryKey struct {
	Spaces       []did.DID
	Hash         mh.Multihash
	TargetClaims []multicodec.Code
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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