providerindex

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: Apache-2.0, MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIgnoreFiltered = errors.New("claim type is not in list of target claims")

Functions

func Cache added in v1.0.0

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

Types

type ContentToClaimsMapper added in v1.0.0

type ContentToClaimsMapper interface {
	GetClaims(ctx context.Context, contentHash multihash.Multihash) (claimsCids []cid.Cid, err error)
}

ContentToClaimsMapper maps content hashes to claim cids

type LegacyClaimsFinder added in v1.0.0

type LegacyClaimsFinder interface {
	// Find returns a list of claims for a given content hash.
	// Implementations should return an empty slice and no error if no results are found.
	Find(ctx context.Context, contentHash multihash.Multihash, targetClaims []multicodec.Code) ([]model.ProviderResult, error)
}

LegacyClaimsFinder is a read-only interface to find claims on a legacy system

type LegacyClaimsStore added in v1.0.0

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

LegacyClaimsStore allows finding claims on a legacy store

func NewLegacyClaimsStore added in v1.0.0

func NewLegacyClaimsStore(contentToClaimsMappers []ContentToClaimsMapper, claimStore contentclaims.Finder, claimsUrl string) (LegacyClaimsStore, error)

NewLegacyClaimsStore builds a new store able to find claims in legacy services.

It uses a series of mappers to fetch claims from. Mappers will be consulted in order, so their positions in the list define their priority, with the first position being the top priority. This is important because the claims returned by Find will be the ones coming from the first mapper that returns relevant claims.

func (LegacyClaimsStore) Find added in v1.0.0

func (ls LegacyClaimsStore) Find(ctx context.Context, contentHash multihash.Multihash, targetClaims []multicodec.Code) ([]model.ProviderResult, error)

Find looks for the corresponding claims for a given content hash in the mapper and then fetches the claims from the claims store. Find will look for relevant claims (as indicated by targetClaims) in content-to-claims mappers in the order they were specified when this LegacyClaimsStore was created (see NewLegacyClaimsStore). As soon as a mapper returns relevant claims, these will be returned and no more mappers will be checked.

type MockContentToClaimsMapper added in v1.2.1

type MockContentToClaimsMapper struct {
	mock.Mock
}

MockContentToClaimsMapper is an autogenerated mock type for the ContentToClaimsMapper type

func NewMockContentToClaimsMapper added in v1.2.1

func NewMockContentToClaimsMapper(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockContentToClaimsMapper

NewMockContentToClaimsMapper creates a new instance of MockContentToClaimsMapper. 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 (*MockContentToClaimsMapper) EXPECT added in v1.2.1

func (*MockContentToClaimsMapper) GetClaims added in v1.2.1

func (_m *MockContentToClaimsMapper) GetClaims(ctx context.Context, contentHash multihash.Multihash) ([]cid.Cid, error)

GetClaims provides a mock function with given fields: ctx, contentHash

type MockContentToClaimsMapper_Expecter added in v1.2.1

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

func (*MockContentToClaimsMapper_Expecter) GetClaims added in v1.2.1

func (_e *MockContentToClaimsMapper_Expecter) GetClaims(ctx interface{}, contentHash interface{}) *MockContentToClaimsMapper_GetClaims_Call

GetClaims is a helper method to define mock.On call

  • ctx context.Context
  • contentHash multihash.Multihash

type MockContentToClaimsMapper_GetClaims_Call added in v1.2.1

type MockContentToClaimsMapper_GetClaims_Call struct {
	*mock.Call
}

MockContentToClaimsMapper_GetClaims_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetClaims'

func (*MockContentToClaimsMapper_GetClaims_Call) Return added in v1.2.1

func (*MockContentToClaimsMapper_GetClaims_Call) Run added in v1.2.1

func (*MockContentToClaimsMapper_GetClaims_Call) RunAndReturn added in v1.2.1

type MockLegacyClaimsFinder added in v1.2.1

type MockLegacyClaimsFinder struct {
	mock.Mock
}

MockLegacyClaimsFinder is an autogenerated mock type for the LegacyClaimsFinder type

func NewMockLegacyClaimsFinder added in v1.2.1

func NewMockLegacyClaimsFinder(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockLegacyClaimsFinder

NewMockLegacyClaimsFinder creates a new instance of MockLegacyClaimsFinder. 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 (*MockLegacyClaimsFinder) EXPECT added in v1.2.1

func (*MockLegacyClaimsFinder) Find added in v1.2.1

func (_m *MockLegacyClaimsFinder) Find(ctx context.Context, contentHash multihash.Multihash, targetClaims []multicodec.Code) ([]model.ProviderResult, error)

Find provides a mock function with given fields: ctx, contentHash, targetClaims

type MockLegacyClaimsFinder_Expecter added in v1.2.1

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

func (*MockLegacyClaimsFinder_Expecter) Find added in v1.2.1

func (_e *MockLegacyClaimsFinder_Expecter) Find(ctx interface{}, contentHash interface{}, targetClaims interface{}) *MockLegacyClaimsFinder_Find_Call

Find is a helper method to define mock.On call

  • ctx context.Context
  • contentHash multihash.Multihash
  • targetClaims []multicodec.Code

type MockLegacyClaimsFinder_Find_Call added in v1.2.1

type MockLegacyClaimsFinder_Find_Call struct {
	*mock.Call
}

MockLegacyClaimsFinder_Find_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Find'

func (*MockLegacyClaimsFinder_Find_Call) Return added in v1.2.1

func (*MockLegacyClaimsFinder_Find_Call) Run added in v1.2.1

func (*MockLegacyClaimsFinder_Find_Call) RunAndReturn added in v1.2.1

type MockProviderIndex added in v1.2.1

type MockProviderIndex struct {
	mock.Mock
}

MockProviderIndex is an autogenerated mock type for the ProviderIndex type

func NewMockProviderIndex added in v1.2.1

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 v1.2.1

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

Cache provides a mock function with given fields: ctx, provider, contextID, digests, meta

func (*MockProviderIndex) EXPECT added in v1.2.1

func (*MockProviderIndex) Find added in v1.2.1

Find provides a mock function with given fields: _a0, _a1

func (*MockProviderIndex) Publish added in v1.2.1

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

Publish provides a mock function with given fields: ctx, provider, contextID, digests, meta

type MockProviderIndex_Cache_Call added in v1.2.1

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 v1.2.1

func (*MockProviderIndex_Cache_Call) Run added in v1.2.1

func (*MockProviderIndex_Cache_Call) RunAndReturn added in v1.2.1

type MockProviderIndex_Expecter added in v1.2.1

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

func (*MockProviderIndex_Expecter) Cache added in v1.2.1

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 v1.2.1

func (_e *MockProviderIndex_Expecter) Find(_a0 interface{}, _a1 interface{}) *MockProviderIndex_Find_Call

Find is a helper method to define mock.On call

  • _a0 context.Context
  • _a1 QueryKey

func (*MockProviderIndex_Expecter) Publish added in v1.2.1

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 v1.2.1

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 v1.2.1

func (*MockProviderIndex_Find_Call) Run added in v1.2.1

func (*MockProviderIndex_Find_Call) RunAndReturn added in v1.2.1

type MockProviderIndex_Publish_Call added in v1.2.1

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 v1.2.1

func (*MockProviderIndex_Publish_Call) Run added in v1.2.1

func (*MockProviderIndex_Publish_Call) RunAndReturn added in v1.2.1

type NoResultsLegacyClaimsFinder added in v1.0.0

type NoResultsLegacyClaimsFinder struct{}

NoResultsLegacyClaimsFinder is a LegacyClaimsFinder that returns no results. It can be used when accessing claims in a legacy system is not required

func NewNoResultsLegacyClaimsFinder added in v1.0.0

func NewNoResultsLegacyClaimsFinder() NoResultsLegacyClaimsFinder

func (NoResultsLegacyClaimsFinder) Find added in v1.0.0

func (f NoResultsLegacyClaimsFinder) Find(ctx context.Context, contentHash multihash.Multihash, targetClaims []multicodec.Code) ([]model.ProviderResult, error)

Find always returns no results

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 v1.0.0

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 v1.0.0

func New(providerStore types.ProviderStore, findClient ipnifind.Finder, publisher publisher.Publisher, legacyClaims LegacyClaimsFinder) *ProviderIndexService

func (*ProviderIndexService) Cache added in v1.0.0

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 v1.0.0

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 v1.0.0

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
}

type RemoteSyncer added in v1.0.0

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

func NewRemoteSyncer added in v1.0.0

func NewRemoteSyncer(providerStore types.ProviderStore, store Store) *RemoteSyncer

func (*RemoteSyncer) HandleRemoteSync added in v1.0.0

func (rs *RemoteSyncer) HandleRemoteSync(ctx context.Context, head, prev ipld.Link)

type Store added in v1.0.0

type Store interface {
	store.EntriesReadable
	store.AdvertReadable
}

Jump to

Keyboard shortcuts

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