Documentation
¶
Overview ¶
Package provider represents a reference implementation of an index provider. It integrates with the indexer node protocol, "storetheinex" in order to advertise the availability of a list of multihashes as an IPLD DAG. For the complete advertisement IPLD schema, see:
A reference implementation of provider.Interface can be found in engine.Engine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoCallback is thrown when no callback has been defined. ErrNoCallback = errors.New("no callback is registered") // ErrContextIDNotFound signals that no item is associated to the given context ID. ErrContextIDNotFound = errors.New("context ID not found") // ErrAlreadyAdvertised indicates that an advertisement for identical // content was already published. ErrAlreadyAdvertised = errors.New("advertisement already published") )
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback func(ctx context.Context, contextID []byte) (MultihashIterator, error)
Callback is used by provider to look up a list of multihashes associated to a context ID. The callback must be deterministic: it must produce the same list of multihashes in the same order for the same context ID.
See: Interface.NotifyPut, Interface.NotifyRemove, MultihashIterator.
type Interface ¶
type Interface interface {
// PublishLocal appends adv to the locally stored advertisement chain and
// returns the corresponding CID to it. This function does not publish the
// changes to the advertisement chain onto gossip pubsub channel. Use
// Publish instead if indexer nodes must be made aware of the appended
// advertisement.
//
// See: Publish.
PublishLocal(context.Context, schema.Advertisement) (cid.Cid, error)
// Publish appends adv to the locally stored advertisement chain, and
// publishes the new advertisement onto gossip pubsub. The CID returned
// represents the ID of the advertisement appended to the chain.
Publish(context.Context, schema.Advertisement) (cid.Cid, error)
// RegisterCallback registers the callback used by the provider to look up
// a list of multihashes by context ID. Only a single callback is
// supported; repeated calls to this function will replace the previous
// callback.
RegisterCallback(Callback)
// NotifyPut signals the provider that the list of multihashes looked up by
// the given contextID is available. The given contextID is then used to
// look up the list of multihashes via Callback. An advertisement is then
// generated, appended to the chain of advertisements and published onto
// the gossip pubsub channel.
//
// A Callback must be registered prior to using this function.
// ErrNoCallback is returned if no such callback is registered.
//
// The metadata is data that provides hints about how to retrieve data and
// is protocol dependant. The metadata must at least specify a protocol
// ID, but its data is optional.
//
// If both the contextID and metadata are the same as a previous call to
// NotifyPut, then ErrAlreadyAdvertised is returned.
//
// This function returns the ID of the advertisement published.
NotifyPut(ctx context.Context, contextID []byte, metadata stiapi.Metadata) (cid.Cid, error)
// NotifyRemove sginals to the provider that the multihashes that
// corresponded to the given contextID are no longer available. An advertisement
// is then generated, appended to the chain of advertisements and published
// onto the gossip pubsub channel.
// The given contextID must have previously been put via NotifyPut.
// If not found ErrContextIDNotFound is returned.
//
// This function returns the ID of the advertisement published.
NotifyRemove(ctx context.Context, contextID []byte) (cid.Cid, error)
// GetAdv gets the advertisement that corresponds to the given cid.
GetAdv(context.Context, cid.Cid) (schema.Advertisement, error)
// GetLatestAdv gets the latest advertisement on this provider's
// advertisement chain and the CID to which it corresponds.
GetLatestAdv(context.Context) (cid.Cid, schema.Advertisement, error)
// Shutdown shuts down this provider, and blocks until all resources
// occupied by it are discared. After calling this function the provider
// is no longer available for use.
Shutdown() error
}
Interface represents an index provider that manages the advertisement of multihashes to indexer nodes.
type MultihashIterator ¶
type MultihashIterator interface {
// Next returns the next multihash in the list of mulitihashes. The
// iterator fails fast: errors that occur during iteration are returned
// immediately. This function returns a zero multihash and io.EOF when
// there are no more elements to return.
Next() (multihash.Multihash, error)
}
MultihashIterator iterates over a list of multihashes.
See: CarMultihashIterator.
func CarMultihashIterator ¶
func CarMultihashIterator(idx carindex.IterableIndex) (MultihashIterator, error)
CarMultihashIterator constructs a new MultihashIterator from a CAR index.
This iterator supplies multihashes in deterministic order of their corresponding CAR offset. The order is maintained consistently regardless of the underlying IterableIndex implementation.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cardatatransfer privdes a datatransfer server that can be used to retrieve multihashes supplied via engine.Engine and supplier.CarSupplier as the provider.Callback.
|
Package cardatatransfer privdes a datatransfer server that can be used to retrieve multihashes supplied via engine.Engine and supplier.CarSupplier as the provider.Callback. |
|
stores
Package stores is copy pasted from go-fil-markets stores package - there is no novel code here.
|
Package stores is copy pasted from go-fil-markets stores package - there is no novel code here. |
|
cmd
module
|
|
|
Package engine provides a reference implementation of the provider.Interface in order to advertise the availability of a list of multihashes to indexer nodes such as "storetheindex".
|
Package engine provides a reference implementation of the provider.Interface in order to advertise the availability of a list of multihashes to indexer nodes such as "storetheindex". |
|
lrustore
Package lrustore provides a datastore wrapper that limits the number of items stored to the specified capacity.
|
Package lrustore provides a datastore wrapper that limits the number of items stored to the specified capacity. |
|
Package metadata captures the metadata types known by the index-provider.
|
Package metadata captures the metadata types known by the index-provider. |
|
Package mock_provider is a generated GoMock package.
|
Package mock_provider is a generated GoMock package. |
|
server
|
|
|
admin/http
Package adminserver provides a HTTP server that allows to perform administrative operations.
|
Package adminserver provides a HTTP server that allows to perform administrative operations. |
|
Package supplier provides mechanisms to supply mulithashes to an index-provider engine via provider.Callback.
|
Package supplier provides mechanisms to supply mulithashes to an index-provider engine via provider.Callback. |