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 ( // ErrNoMultihashLister signals that no provider.MultihashLister is registered for lookup. ErrNoMultihashLister = errors.New("no multihash lister is registered") // ErrContextIDNotFound signals that no item is associated to the given context ID. ErrContextIDNotFound = errors.New("context ID not found") // ErrAlreadyAdvertised signals that an advertisement for identical content was already // published. ErrAlreadyAdvertised = errors.New("advertisement already published") )
Functions ¶
This section is empty.
Types ¶
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)
// RegisterMultihashLister registers the hook that is used by the provider to look up
// a list of multihashes by context ID. Only a single registration is
// supported; repeated calls to this function will replace the previous
// registration.
RegisterMultihashLister(MultihashLister)
// 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 MultihashLister. An advertisement is then
// generated, appended to the chain of advertisements and published onto
// the gossip pubsub channel.
//
// A MultihashLister must be registered prior to using this function.
// ErrNoMultihashLister is returned if no such lister 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, md metadata.Metadata) (cid.Cid, error)
// NotifyRemove signals 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 discarded. After calling this function the provider
// is no longer available for use.
Shutdown() error
}
Interface represents an index provider that manages the advertisement for 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. Returns error if duplicate offsets detected.
func SliceMultihashIterator ¶ added in v0.8.0
func SliceMultihashIterator(mhs []multihash.Multihash) MultihashIterator
SliceMultihashIterator constructs a new MultihashIterator from a slice of multihashes.
type MultihashLister ¶ added in v0.5.1
type MultihashLister func(ctx context.Context, contextID []byte) (MultihashIterator, error)
MultihashLister lists the multihashes that correspond to a given contextID. The lister 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.
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.MultihashLister.
|
Package cardatatransfer privdes a datatransfer server that can be used to retrieve multihashes supplied via engine.Engine and supplier.CarSupplier as the provider.MultihashLister. |
|
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
|
|
|
provider
command
Provider CLI can be used to start an index-provider daemon that runs a reference implementation of the provider interface, with ability to publish advertisements by importing/removing CAR files and server content retrieval via DataTransfer GraphSync protocol.
|
Provider CLI can be used to start an index-provider daemon that runs a reference implementation of the provider interface, with ability to publish advertisements by importing/removing CAR files and server content retrieval via DataTransfer GraphSync protocol. |
|
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". |
|
chunker
Package chunker provides functionality for chunking entries chain generated from provider.MultihashIterator, represented as EntriesChunker interface.
|
Package chunker provides functionality for chunking entries chain generated from provider.MultihashIterator, represented as EntriesChunker interface. |
|
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.MultihashLister The only implemented mechanism is CarSupplier, that in conjunction with an engine allows a user to advertise multihashes by simply providing CAR files.
|
Package supplier provides mechanisms to supply mulithashes to an index-provider engine via provider.MultihashLister The only implemented mechanism is CarSupplier, that in conjunction with an engine allows a user to advertise multihashes by simply providing CAR files. |