providerindex

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0, MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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) ([]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(contentToClaimsMapper ContentToClaimsMapper, claimStore types.ContentClaimsStore, claimsUrl string) (LegacyClaimsStore, error)

func (LegacyClaimsStore) Find added in v1.0.0

func (ls LegacyClaimsStore) Find(ctx context.Context, contentHash multihash.Multihash) ([]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

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) ([]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