Documentation ¶
Index ¶
- Variables
- type BytesMount
- type Counting
- type FSMount
- type FileMount
- type Info
- type Kind
- type Mount
- type NopCloser
- type Reader
- type Registry
- type Stat
- type Upgrader
- func (u *Upgrader) Close() error
- func (u *Upgrader) DeleteTransient() error
- func (u *Upgrader) Deserialize(url *url.URL) error
- func (u *Upgrader) Fetch(ctx context.Context) (Reader, error)
- func (u *Upgrader) Info() Info
- func (u *Upgrader) Serialize() *url.URL
- func (u *Upgrader) Stat(ctx context.Context) (Stat, error)
- func (u *Upgrader) TimesFetched() int
- func (u *Upgrader) TransientPath() string
- func (u *Upgrader) Underlying() Mount
Constants ¶
This section is empty.
Variables ¶
var ( // ErrSeekUnsupported is returned when Seek is called on a mount that is // not seekable. ErrSeekUnsupported = errors.New("mount does not support seek") // ErrRandomAccessUnsupported is returned when ReadAt is called on a mount // that does not support random access. ErrRandomAccessUnsupported = errors.New("mount does not support random access") )
var ( // ErrUnrecognizedScheme is returned by Instantiate() when attempting to // initialize a Mount with an unrecognized URL scheme. ErrUnrecognizedScheme = errors.New("unrecognized mount scheme") // ErrUnrecognizedType is returned by Encode() when attempting to // represent a Mount whose type has not been registered. ErrUnrecognizedType = errors.New("unrecognized mount type") )
Functions ¶
This section is empty.
Types ¶
type BytesMount ¶
type BytesMount struct {
Bytes []byte
}
BytesMount encloses a byte slice. It is mainly used for testing. The Upgrader passes through it.
func (*BytesMount) Close ¶
func (b *BytesMount) Close() error
func (*BytesMount) Deserialize ¶
func (b *BytesMount) Deserialize(u *url.URL) error
func (*BytesMount) Info ¶
func (b *BytesMount) Info() Info
func (*BytesMount) Serialize ¶
func (b *BytesMount) Serialize() *url.URL
type Counting ¶
type Counting struct { Mount // contains filtered or unexported fields }
Counting is a mount that proxies to another mount and counts the number of calls made to Fetch. It is mostly used in tests.
type FSMount ¶
FSMount is a mount that opens the file indicated by Path, using the provided fs.FS. Given that io/fs does not support random access patterns, this mount requires an Upgrade. It is suitable for testing.
type Info ¶
type Info struct { // Kind indicates the kind of mount. Kind Kind // TODO convert to bitfield AccessSequential bool AccessSeek bool AccessRandom bool }
Info describes a mount.
type Kind ¶
type Kind int
Kind is an enum describing the source of a Mount.
const ( // KindLocal indicates that the asset represented by this mount is of // transient provenance (e.g. filesystem mount). A call to Fetch() will open a // transient stream. // // Note that mounts of this kind may be indirectly backed by underlying storage // (e.g. NFS, FUSE), but from the viewpoint of the DAG store, the resource // is considered transient. KindLocal Kind = iota // KindRemote indicates that the asset represented by this mount is // fetched from a underlying provenance (e.g. HTTP, Filecoin sealing cluster, // IPFS, etc.) A call to Fetch() is likely to download the asset from // a underlying source, thus it is advisable to cache the asset locally once // downloaded. KindRemote )
type Mount ¶
type Mount interface { io.Closer // Fetch returns a Reader for this mount. Not all read access methods // may be supported. Check the Info object to determine which access methods // are effectively supported. // // To seamlessly upgrade a Mount to a fully-featured mount by using a transient // transient file, use the Upgrader. Fetch(ctx context.Context) (Reader, error) // Info describes the Mount. This is a pure function. Info() Info // Stat describes the underlying resource. Stat(ctx context.Context) (Stat, error) // Serialize returns a canonical URL that can be used to revive the Mount // after a restart. Serialize() *url.URL // Deserialize configures this Mount from the specified URL. Deserialize(*url.URL) error }
Mount is a pluggable component that represents the original location of the data contained in a shard known to the DAG store. The backing resource is a CAR file.
Shards can be located anywhere, and can come and go dynamically e.g. Filecoin deals expire, removable media is attached/detached, or the IPFS user purges content.
It is possible to mount shards with CARs accessible through the transient filesystem, detachable mounts, NFS mounts, distributed filesystems like Ceph/GlusterFS, HTTP, FTP, etc.
Mount implementations are free to define constructor parameters or setters to supply arguments needed to initialize the mount, such as credentials, sector IDs, CIDs, etc.
MountTypes must define a deterministic URL representation which will be used to:
a. deserialise the Mount from DAG persistence when resuming the system by using a pre-defined Mount factory mapped to the URL scheme. b. support adding mounts from configuration files.
type Reader ¶
Reader is a fully-featured Reader returned from MountTypes. It is the union of the standard IO sequential access method (Read), with seeking ability (Seek), as well random access (ReadAt).
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a registry of Mount factories known to the DAG store.
func (*Registry) Instantiate ¶
Instantiate instantiates a new Mount from a URL.
It looks up the Mount template in the registry based on the URL scheme, creates a copy, and calls Deserialize() on it with the supplied URL before returning.
It propagates any error returned by the Mount#Deserialize method. If the scheme is not recognized, it returns ErrUnrecognizedScheme.
func (*Registry) Register ¶
Register adds a new mount type to the registry under the specified scheme.
The supplied Mount is used as a template to create new instances.
This means that the provided Mount can contain environmental configuration that will be automatically carried over to all instances.
type Stat ¶
type Stat struct { // Exists indicates if the asset exists. Exists bool // Size is the size of the asset referred to by this Mount. Size int64 // Ready indicates whether the mount can serve the resource immediately, or // if it needs to do work prior to serving it. Ready bool }
Stat
type Upgrader ¶
type Upgrader struct {
// contains filtered or unexported fields
}
Upgrader is a bridge to upgrade any Mount into one with full-featured Reader capabilities, whether the original mount is of remote or local kind. It does this by managing a local transient copy.
If the underlying mount is fully-featured, the Upgrader has no effect, and simply passes through to the underlying mount.
func Upgrade ¶
func Upgrade(underlying Mount, throttler throttle.Throttler, rootdir, key string, initial string) (*Upgrader, error)
Upgrade constructs a new Upgrader for the underlying Mount. If provided, it will reuse the file in path `initial` as the initial transient copy. Whenever a new transient copy has to be created, it will be created under `rootdir`.
func (*Upgrader) DeleteTransient ¶
DeleteTransient deletes the transient associated with this Upgrader, if one exists. It is the caller's responsibility to ensure the transient is not in use. If the tracked transient is gone, this will reset the internal state to "" (no transient) to enable recovery.
func (*Upgrader) TimesFetched ¶ added in v0.3.0
TimesFetched returns the number of times that the underlying has been fetched.
func (*Upgrader) TransientPath ¶
TransientPath returns the local path of the transient file, if one exists.
func (*Upgrader) Underlying ¶ added in v0.3.0
Underlying returns the underlying mount.