types

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: Apache-2.0, MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyNotFound = errors.New("key not found")

ErrKeyNotFound means the key did not exist in the cache

View Source
var ErrNoRootBlock = errors.New("query root block not found in car")

ErrNoRootBlock indicates a root that is specified but not found in a CAR file

View Source
var ErrWrongRootCount = errors.New("query result should have exactly one root")

ErrWrongRootCount indicates a car file with multiple roots being unable to interpret as a query result

Functions

This section is empty.

Types

type Cache

type Cache[Key, Value any] interface {
	Set(ctx context.Context, key Key, value Value, expires bool) error
	SetExpirable(ctx context.Context, key Key, expires bool) error
	Get(ctx context.Context, key Key) (Value, error)
}

Cache describes a generic cache interface

type ContentClaimsCache added in v1.0.0

type ContentClaimsCache Cache[cid.Cid, delegation.Delegation]

ContentClaimsCache caches fetched content claims

type ContentClaimsStore

type ContentClaimsStore Store[ipld.Link, delegation.Delegation]

ContentClaimsStore stores published content claims

type ContextID

type ContextID struct {
	Space *did.DID
	Hash  mh.Multihash
}

ContextID describes the data used to calculate a context id for IPNI

func (ContextID) ToEncoded

func (c ContextID) ToEncoded() (EncodedContextID, error)

ToEncoded canonically encodes ContextID data

type EncodedContextID

type EncodedContextID []byte

EncodedContextID is the encoded form of context id data that is actually stored in IPNI

type Getter added in v1.0.0

type Getter interface {
	// Get retrieves a claim that has been published or cached by the
	// indexing service. No external sources are consulted.
	Get(ctx context.Context, claim ipld.Link) (delegation.Delegation, error)
}

type Match added in v1.0.0

type Match struct {
	Subject []did.DID
}

Match narrows parameters for locating providers/claims for a set of multihashes

type MockContentClaimsCache added in v1.2.1

type MockContentClaimsCache struct {
	mock.Mock
}

MockContentClaimsCache is an autogenerated mock type for the ContentClaimsCache type

func NewMockContentClaimsCache added in v1.2.1

func NewMockContentClaimsCache(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockContentClaimsCache

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

func (*MockContentClaimsCache) Get added in v1.2.1

Get provides a mock function with given fields: ctx, key

func (*MockContentClaimsCache) Set added in v1.2.1

func (_m *MockContentClaimsCache) Set(ctx context.Context, key cid.Cid, value delegation.Delegation, expires bool) error

Set provides a mock function with given fields: ctx, key, value, expires

func (*MockContentClaimsCache) SetExpirable added in v1.2.1

func (_m *MockContentClaimsCache) SetExpirable(ctx context.Context, key cid.Cid, expires bool) error

SetExpirable provides a mock function with given fields: ctx, key, expires

type MockContentClaimsCache_Expecter added in v1.2.1

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

func (*MockContentClaimsCache_Expecter) Get added in v1.2.1

func (_e *MockContentClaimsCache_Expecter) Get(ctx interface{}, key interface{}) *MockContentClaimsCache_Get_Call

Get is a helper method to define mock.On call

  • ctx context.Context
  • key cid.Cid

func (*MockContentClaimsCache_Expecter) Set added in v1.2.1

func (_e *MockContentClaimsCache_Expecter) Set(ctx interface{}, key interface{}, value interface{}, expires interface{}) *MockContentClaimsCache_Set_Call

Set is a helper method to define mock.On call

  • ctx context.Context
  • key cid.Cid
  • value delegation.Delegation
  • expires bool

func (*MockContentClaimsCache_Expecter) SetExpirable added in v1.2.1

func (_e *MockContentClaimsCache_Expecter) SetExpirable(ctx interface{}, key interface{}, expires interface{}) *MockContentClaimsCache_SetExpirable_Call

SetExpirable is a helper method to define mock.On call

  • ctx context.Context
  • key cid.Cid
  • expires bool

type MockContentClaimsCache_Get_Call added in v1.2.1

type MockContentClaimsCache_Get_Call struct {
	*mock.Call
}

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

func (*MockContentClaimsCache_Get_Call) Return added in v1.2.1

func (*MockContentClaimsCache_Get_Call) Run added in v1.2.1

func (*MockContentClaimsCache_Get_Call) RunAndReturn added in v1.2.1

type MockContentClaimsCache_SetExpirable_Call added in v1.2.1

type MockContentClaimsCache_SetExpirable_Call struct {
	*mock.Call
}

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

func (*MockContentClaimsCache_SetExpirable_Call) Return added in v1.2.1

func (*MockContentClaimsCache_SetExpirable_Call) Run added in v1.2.1

func (*MockContentClaimsCache_SetExpirable_Call) RunAndReturn added in v1.2.1

type MockContentClaimsCache_Set_Call added in v1.2.1

type MockContentClaimsCache_Set_Call struct {
	*mock.Call
}

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

func (*MockContentClaimsCache_Set_Call) Return added in v1.2.1

func (*MockContentClaimsCache_Set_Call) Run added in v1.2.1

func (*MockContentClaimsCache_Set_Call) RunAndReturn added in v1.2.1

type MockContentClaimsStore added in v1.2.1

type MockContentClaimsStore struct {
	mock.Mock
}

MockContentClaimsStore is an autogenerated mock type for the ContentClaimsStore type

func NewMockContentClaimsStore added in v1.2.1

func NewMockContentClaimsStore(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockContentClaimsStore

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

func (*MockContentClaimsStore) Get added in v1.2.1

Get provides a mock function with given fields: ctx, key

func (*MockContentClaimsStore) Put added in v1.2.1

Put provides a mock function with given fields: ctx, key, value

type MockContentClaimsStore_Expecter added in v1.2.1

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

func (*MockContentClaimsStore_Expecter) Get added in v1.2.1

func (_e *MockContentClaimsStore_Expecter) Get(ctx interface{}, key interface{}) *MockContentClaimsStore_Get_Call

Get is a helper method to define mock.On call

  • ctx context.Context
  • key ipld.Link

func (*MockContentClaimsStore_Expecter) Put added in v1.2.1

func (_e *MockContentClaimsStore_Expecter) Put(ctx interface{}, key interface{}, value interface{}) *MockContentClaimsStore_Put_Call

Put is a helper method to define mock.On call

  • ctx context.Context
  • key ipld.Link
  • value delegation.Delegation

type MockContentClaimsStore_Get_Call added in v1.2.1

type MockContentClaimsStore_Get_Call struct {
	*mock.Call
}

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

func (*MockContentClaimsStore_Get_Call) Return added in v1.2.1

func (*MockContentClaimsStore_Get_Call) Run added in v1.2.1

func (*MockContentClaimsStore_Get_Call) RunAndReturn added in v1.2.1

type MockContentClaimsStore_Put_Call added in v1.2.1

type MockContentClaimsStore_Put_Call struct {
	*mock.Call
}

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

func (*MockContentClaimsStore_Put_Call) Return added in v1.2.1

func (*MockContentClaimsStore_Put_Call) Run added in v1.2.1

func (*MockContentClaimsStore_Put_Call) RunAndReturn added in v1.2.1

type MockProviderStore added in v1.2.1

type MockProviderStore struct {
	mock.Mock
}

MockProviderStore is an autogenerated mock type for the ProviderStore type

func NewMockProviderStore added in v1.2.1

func NewMockProviderStore(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockProviderStore

NewMockProviderStore creates a new instance of MockProviderStore. 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 (*MockProviderStore) Add added in v1.2.1

Add provides a mock function with given fields: ctx, key, values

func (*MockProviderStore) EXPECT added in v1.2.1

func (*MockProviderStore) Members added in v1.2.1

Members provides a mock function with given fields: ctx, key

func (*MockProviderStore) SetExpirable added in v1.2.1

func (_m *MockProviderStore) SetExpirable(ctx context.Context, key multihash.Multihash, expires bool) error

SetExpirable provides a mock function with given fields: ctx, key, expires

type MockProviderStore_Add_Call added in v1.2.1

type MockProviderStore_Add_Call struct {
	*mock.Call
}

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

func (*MockProviderStore_Add_Call) Return added in v1.2.1

func (*MockProviderStore_Add_Call) Run added in v1.2.1

func (*MockProviderStore_Add_Call) RunAndReturn added in v1.2.1

type MockProviderStore_Expecter added in v1.2.1

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

func (*MockProviderStore_Expecter) Add added in v1.2.1

func (_e *MockProviderStore_Expecter) Add(ctx interface{}, key interface{}, values ...interface{}) *MockProviderStore_Add_Call

Add is a helper method to define mock.On call

  • ctx context.Context
  • key multihash.Multihash
  • values ...model.ProviderResult

func (*MockProviderStore_Expecter) Members added in v1.2.1

func (_e *MockProviderStore_Expecter) Members(ctx interface{}, key interface{}) *MockProviderStore_Members_Call

Members is a helper method to define mock.On call

  • ctx context.Context
  • key multihash.Multihash

func (*MockProviderStore_Expecter) SetExpirable added in v1.2.1

func (_e *MockProviderStore_Expecter) SetExpirable(ctx interface{}, key interface{}, expires interface{}) *MockProviderStore_SetExpirable_Call

SetExpirable is a helper method to define mock.On call

  • ctx context.Context
  • key multihash.Multihash
  • expires bool

type MockProviderStore_Members_Call added in v1.2.1

type MockProviderStore_Members_Call struct {
	*mock.Call
}

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

func (*MockProviderStore_Members_Call) Return added in v1.2.1

func (*MockProviderStore_Members_Call) Run added in v1.2.1

func (*MockProviderStore_Members_Call) RunAndReturn added in v1.2.1

type MockProviderStore_SetExpirable_Call added in v1.2.1

type MockProviderStore_SetExpirable_Call struct {
	*mock.Call
}

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

func (*MockProviderStore_SetExpirable_Call) Return added in v1.2.1

func (*MockProviderStore_SetExpirable_Call) Run added in v1.2.1

func (*MockProviderStore_SetExpirable_Call) RunAndReturn added in v1.2.1

type MockService added in v1.2.1

type MockService struct {
	mock.Mock
}

MockService is an autogenerated mock type for the Service type

func NewMockService added in v1.2.1

func NewMockService(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockService

NewMockService creates a new instance of MockService. 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 (*MockService) Cache added in v1.2.1

func (_m *MockService) Cache(ctx context.Context, provider peer.AddrInfo, claim delegation.Delegation) error

Cache provides a mock function with given fields: ctx, provider, claim

func (*MockService) EXPECT added in v1.2.1

func (_m *MockService) EXPECT() *MockService_Expecter

func (*MockService) Get added in v1.2.1

func (_m *MockService) Get(ctx context.Context, claim ipld.Link) (delegation.Delegation, error)

Get provides a mock function with given fields: ctx, claim

func (*MockService) Publish added in v1.2.1

func (_m *MockService) Publish(ctx context.Context, claim delegation.Delegation) error

Publish provides a mock function with given fields: ctx, claim

func (*MockService) Query added in v1.2.1

func (_m *MockService) Query(ctx context.Context, q Query) (QueryResult, error)

Query provides a mock function with given fields: ctx, q

type MockService_Cache_Call added in v1.2.1

type MockService_Cache_Call struct {
	*mock.Call
}

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

func (*MockService_Cache_Call) Return added in v1.2.1

func (*MockService_Cache_Call) Run added in v1.2.1

func (*MockService_Cache_Call) RunAndReturn added in v1.2.1

type MockService_Expecter added in v1.2.1

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

func (*MockService_Expecter) Cache added in v1.2.1

func (_e *MockService_Expecter) Cache(ctx interface{}, provider interface{}, claim interface{}) *MockService_Cache_Call

Cache is a helper method to define mock.On call

  • ctx context.Context
  • provider peer.AddrInfo
  • claim delegation.Delegation

func (*MockService_Expecter) Get added in v1.2.1

func (_e *MockService_Expecter) Get(ctx interface{}, claim interface{}) *MockService_Get_Call

Get is a helper method to define mock.On call

  • ctx context.Context
  • claim ipld.Link

func (*MockService_Expecter) Publish added in v1.2.1

func (_e *MockService_Expecter) Publish(ctx interface{}, claim interface{}) *MockService_Publish_Call

Publish is a helper method to define mock.On call

  • ctx context.Context
  • claim delegation.Delegation

func (*MockService_Expecter) Query added in v1.2.1

func (_e *MockService_Expecter) Query(ctx interface{}, q interface{}) *MockService_Query_Call

Query is a helper method to define mock.On call

  • ctx context.Context
  • q Query

type MockService_Get_Call added in v1.2.1

type MockService_Get_Call struct {
	*mock.Call
}

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

func (*MockService_Get_Call) Return added in v1.2.1

func (*MockService_Get_Call) Run added in v1.2.1

func (_c *MockService_Get_Call) Run(run func(ctx context.Context, claim ipld.Link)) *MockService_Get_Call

func (*MockService_Get_Call) RunAndReturn added in v1.2.1

type MockService_Publish_Call added in v1.2.1

type MockService_Publish_Call struct {
	*mock.Call
}

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

func (*MockService_Publish_Call) Return added in v1.2.1

func (*MockService_Publish_Call) Run added in v1.2.1

func (*MockService_Publish_Call) RunAndReturn added in v1.2.1

type MockService_Query_Call added in v1.2.1

type MockService_Query_Call struct {
	*mock.Call
}

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

func (*MockService_Query_Call) Return added in v1.2.1

func (*MockService_Query_Call) Run added in v1.2.1

func (*MockService_Query_Call) RunAndReturn added in v1.2.1

type ProviderStore

ProviderStore caches queries to IPNI

type Publisher added in v1.0.0

type Publisher interface {
	// Cache caches a claim with the service temporarily.
	Cache(ctx context.Context, provider peer.AddrInfo, claim delegation.Delegation) error
	// Publish writes a claim to permanent storage, adds it to an IPNI
	// advertisement, annnounces it to IPNI nodes and caches it.
	Publish(ctx context.Context, claim delegation.Delegation) error
}

type Querier added in v1.0.0

type Querier interface {
	// Query allows claims to be queried by their subject (content CID). It
	// returns claims as well as any relevant indexes.
	Query(ctx context.Context, q Query) (QueryResult, error)
}

type Query added in v1.0.0

type Query struct {
	Type   QueryType
	Hashes []mh.Multihash
	Match  Match
}

Query is a query for several multihashes

type QueryResult added in v1.0.0

type QueryResult interface {
	ipld.View
	// Claims is a list of links to the root block of claims that can be found in this message
	Claims() []ipld.Link
	// Indexes is a list of links to the CID hash of archived sharded dag indexes that can be found in this
	// message
	Indexes() []ipld.Link
}

QueryResult is an encodable result of a query

type QueryType added in v1.2.1

type QueryType int

QueryType allows defining which claims a query is targeting. QueryTypeStandard targets all claims, i.e. Location, Index and Equals

const (
	QueryTypeStandard QueryType = iota
	QueryTypeLocation
	QueryTypeIndexOrLocation
)

func ParseQueryType added in v1.2.1

func ParseQueryType(queryTypeStr string) (QueryType, error)

func (QueryType) String added in v1.2.1

func (qt QueryType) String() string

type Service added in v1.0.0

type Service interface {
	Getter
	Publisher
	Querier
}

Service is the core methods of the indexing service.

type ShardedDagIndexStore

type ShardedDagIndexStore Cache[EncodedContextID, blobindex.ShardedDagIndexView]

ShardedDagIndexStore caches fetched sharded dag indexes

type Store added in v1.0.0

type Store[Key, Value any] interface {
	// Put adds (or replaces) an item in the store.
	Put(ctx context.Context, key Key, value Value) error
	// Get retrieves an existing item from the store. If the item does not exist,
	// it should return [ErrKeyNotFound].
	Get(ctx context.Context, key Key) (Value, error)
}

Store describes a generic storage interface

type ValueSetCache added in v1.2.1

type ValueSetCache[Key, Value any] interface {
	Add(ctx context.Context, key Key, values ...Value) (uint64, error)
	SetExpirable(ctx context.Context, key Key, expires bool) error
	Members(ctx context.Context, key Key) ([]Value, error)
}

ValueSetCache describes a cache interface whose values are sets

Jump to

Keyboard shortcuts

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