Documentation ¶
Overview ¶
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.
Index ¶
- Variables
- type CarSupplier
- func (cs *CarSupplier) Close() error
- func (cs *CarSupplier) List(ctx context.Context) ([]string, error)
- func (cs *CarSupplier) ListMultihashes(ctx context.Context, p peer.ID, contextID []byte) (provider.MultihashIterator, error)
- func (cs *CarSupplier) Put(ctx context.Context, contextID []byte, path string, metadata metadata.Metadata) (cid.Cid, error)
- func (cs *CarSupplier) ReadOnlyBlockstore(contextID []byte) (ClosableBlockstore, error)
- func (cs *CarSupplier) Remove(ctx context.Context, contextID []byte) (cid.Cid, error)
- type ClosableBlockstore
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("no CID iterator found for given key")
ErrNotFound signals that CidIteratorSupplier has no iterator corresponding to the given key.
Functions ¶
This section is empty.
Types ¶
type CarSupplier ¶
type CarSupplier struct {
// contains filtered or unexported fields
}
CarSupplier supplies multihashes to an implementation of Provider.Interface via provider.MultihashLister. It allows the users to advertise addition and removal of multihashes within CAR files by simply calling CarSupplier.Put and CarSupplier.Remove.
CarSupplier accepts both CARv1 and CARv2, and will automatically generate an index if one is not present or the index codec and characteristics are not sufficient for provider.Interface purposes.
See: engine.New, CarSupplier.Put, CarSupplier.Remove.
func NewCarSupplier ¶
func NewCarSupplier(eng provider.Interface, ds datastore.Datastore, opts ...car.ReadOption) *CarSupplier
NewCarSupplier instantiates a new CarSupplier and registers it as the provider.MultihashLister of the given provider.Interface.
func (*CarSupplier) Close ¶
func (cs *CarSupplier) Close() error
Close permanently closes this supplier. After calling Close this supplier is no longer usable.
func (*CarSupplier) List ¶
func (cs *CarSupplier) List(ctx context.Context) ([]string, error)
List lists the CAR paths that are supplied by this supplier.
See: CarSupplier.Put
func (*CarSupplier) ListMultihashes ¶
func (cs *CarSupplier) ListMultihashes(ctx context.Context, p peer.ID, contextID []byte) (provider.MultihashIterator, error)
ListMultihashes supplies an iterator over CIDs of the CAR file that corresponds to the given key. An error is returned if no CAR file is found for the key.
func (*CarSupplier) Put ¶
func (cs *CarSupplier) Put(ctx context.Context, contextID []byte, path string, metadata metadata.Metadata) (cid.Cid, error)
Put makes the CAR at the given path, and identified by the given ID, suppliable by this supplier. The return CID can then be used via Supply to get an iterator over CIDs that belong to the CAR.
This function accepts both CARv1 and CARv2 formats.
func (*CarSupplier) ReadOnlyBlockstore ¶
func (cs *CarSupplier) ReadOnlyBlockstore(contextID []byte) (ClosableBlockstore, error)
ReadOnlyBlockstore returns a CAR blockstore interface for the given blockstore key
func (*CarSupplier) Remove ¶
func (cs *CarSupplier) Remove(ctx context.Context, contextID []byte) (cid.Cid, error)
Remove removes the CAR at the given path from the list of suppliable CID iterators. If the CAR at given path is not known, this function will return an error. This function accepts both CARv1 and CARv2 formats.
type ClosableBlockstore ¶
type ClosableBlockstore interface { bstore.Blockstore io.Closer }
ClosableBlockstore is a blockstore that can be closed