Documentation
¶
Overview ¶
Package supplier provides mechanisms to supply mulithashes to an index-provider engine via provider.Callback. 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) Callback(ctx context.Context, contextID []byte) (provider.MultihashIterator, error)
- func (cs *CarSupplier) Close() error
- func (cs *CarSupplier) Put(ctx context.Context, contextID []byte, path string, metadata stiapi.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.Callback. 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 instantiateas a new CarSupplier and registers it as the provider.Callback of the given provider.Interface.
func (*CarSupplier) Callback ¶
func (cs *CarSupplier) Callback(ctx context.Context, contextID []byte) (provider.MultihashIterator, error)
Callback 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) Close ¶
func (cs *CarSupplier) Close() error
Close permanently closes this supplier. After calling Close this supplier is no longer usable.
func (*CarSupplier) Put ¶
func (cs *CarSupplier) Put(ctx context.Context, contextID []byte, path string, metadata stiapi.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