Documentation ¶
Overview ¶
Package storage contains the resources required to interact with an object store.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrObjectAlreadyExists is returned when an object already exists. ErrObjectAlreadyExists error = errors.New("the object already exists") // ErrObjectDoesNotExist is returned when an object does not exist. ErrObjectDoesNotExist error = errors.New("the object does not exist") // ErrObjectIsDir is returned when an object is a directory. ErrObjectIsDir error = errors.New("the object is a directory") // ErrCopyObject is returned when an object cannot be copied. ErrCopyObject error = errors.New("error while copying the object") // ErrPutObject is returned when an object cannot be created. ErrPutObject error = errors.New("error while putting the object") // ErrGetObject is returned when an object cannot be retrieved. ErrGetObject error = errors.New("error while getting the object") // ErrHeadObject is returned when an object's metadata cannot be retrieved. ErrHeadObject error = errors.New("error while getting the object head") // ErrDeleteObject is returned when an object cannot be deleted. ErrDeleteObject error = errors.New("error while deleting the object") // ErrURLJoinPath is returned when paths cannot be joined. ErrURLJoinPath error = errors.New("error during url.JoinPath") // ErrListObjects is returned when objects cannot be listed. ErrListObjects error = errors.New("error while listing objects") // ErrOperationNotSupported is returned when an operation is not supported. ErrOperationNotSupported error = errors.New("the object store does not support this operation") // ErrWriter is returned when a writer cannot be retrieved. ErrWriter error = errors.New("error while getting writer") // ErrSeekOffset is returned when a seek offset is invalid ErrSeekOffset error = errors.New("invalid seek offset") // ErrSeekWhence is returned when a seek whence is invalid. ErrSeekWhence error = errors.New("invalid seek whence") // ErrReadAt is returned when an object cannot be read. ErrReadAt error = errors.New("error while reading the object") )
Functions ¶
This section is empty.
Types ¶
type ListIterator ¶
type ListIterator struct {
// contains filtered or unexported fields
}
ListIterator is a wrapper around List that performs paging if required.
func NewListIterator ¶
func NewListIterator(prefix Path, store ObjectStore) *ListIterator
NewListIterator creates a new ListIterator instance.
func (*ListIterator) Next ¶
func (listIterator *ListIterator) Next() (*ObjectMeta, error)
Next returns the next object in a list. When there are no more objects, return nil and the error ErrObjectDoesNotExist
type ListResult ¶
type ListResult struct { /// Prefixes that are common (like directories) // CommonPrefixes []Path /// Object metadata for the listing Objects []ObjectMeta NextToken string }
ListResult is the result of a list call that includes objects, prefixes (directories) and a token for the next set of results. Individual result sets may be limited to 1,000 objects based on the underlying object storage's limitations.
type LockData ¶
type LockData struct { // Source object key Source string `json:"source"` // Destination object key Destination string `json:"destination"` Version int64 `json:"version"` }
LockData stores an attempt to rename `source` into `destination`
type ObjectMeta ¶
type ObjectMeta struct { /// The full path to the object Location Path /// The last modified time LastModified time.Time /// The size in bytes of the object Size int64 }
ObjectMeta is the metadata that describes an object.
type ObjectReaderAtSeeker ¶
type ObjectReaderAtSeeker struct {
// contains filtered or unexported fields
}
ObjectReaderAtSeeker supports the IO interfaces Seeker, Reader, and ReaderAt.
func NewObjectReaderAtSeeker ¶
func NewObjectReaderAtSeeker(location Path, store ObjectStore) (*ObjectReaderAtSeeker, error)
NewObjectReaderAtSeeker creates a new ObjectReaderAtSeeker instance.
func (*ObjectReaderAtSeeker) Read ¶
func (reader *ObjectReaderAtSeeker) Read(p []byte) (n int, err error)
type ObjectStore ¶
type ObjectStore interface { /// Save the provided bytes to the specified location. Put(location Path, bytes []byte) error /// Return the bytes that are stored at the specified location. Get(location Path) ([]byte, error) // /// Return the bytes that are stored at the specified location // /// in the given byte ranges // GetRanges(location Path, ranges []Range) ([]byte, error) /// Return the metadata for the specified location Head(location Path) (ObjectMeta, error) // /// Delete the object at the specified location. Delete(location Path) error /// Delete the folder at the specified location. DeleteFolder(location Path) error /// List the objects with the given prefix. This may be limited to a certain number of objects (e.g. 1000) /// based on the underlying object storage's limitations. /// If a previousResult is provided and the store supports paging, the next page of results will be returned. /// /// Prefixes are evaluated on a path segment basis, i.e. `foo/bar/` is a prefix of `foo/bar/x` but not of /// `foo/bar_baz/x`. List(prefix Path, previousResult *ListResult) (ListResult, error) /// List all objects with the given prefix. If the underlying object storage returns a limited number of objects, /// this will perform paging as required to return all results /// /// Prefixes are evaluated on a path segment basis, i.e. `foo/bar/` is a prefix of `foo/bar/x` but not of /// `foo/bar_baz/x`. ListAll(prefix Path) (ListResult, error) /// Returns true if this store returns list results sorted IsListOrdered() bool // /// Move an object from one path to another in the same object store. // /// // /// By default, this is implemented as a copy and then delete source. It may not // /// check when deleting source that it was the same object that was originally copied. // /// /// If there exists an object at the destination, it will be overwritten. Rename(from Path, to Path) error // Will return an error if the destination already has an object. RenameIfNotExists(from Path, to Path) error /// Allow ObjectReaderAtSeeker to support the ReaderAt io interface /// Excerpt from the ReaderAt comments: // // ReadAt reads len(p) bytes into p starting at offset off in the // underlying input source. It returns the number of bytes // read (0 <= n <= len(p)) and any error encountered. // ... // If ReadAt is reading from an input source with a seek offset, // ReadAt should not affect nor be affected by the underlying // seek offset. ReadAt(location Path, p []byte, off int64, max int64) (n int, err error) // Whether or not this store can be used as an io.Writer SupportsWriter() bool // Allow use of an ObjectStore as an io.Writer // If error is nil, then the returned function should be called with a defer to close resources // Writer may not be supported for all store types Writer(to Path, flag int) (io.Writer, func() error, error) // BaseURI gets a store's base URI. BaseURI() Path }
ObjectStore Universal API to multiple object store services.
type Path ¶
type Path struct {
Raw string
}
Path stores the location of an object. TODO Implement methods for path
func PathFromIter ¶
PathFromIter joins a list of strings to create a path.
func (Path) CommitPathForVersion ¶
CommitPathForVersion retrieves the commit URI for a given version.
Directories ¶
Path | Synopsis |
---|---|
Package filestore contains the resources required to interact with an file store.
|
Package filestore contains the resources required to interact with an file store. |
Package s3store contains the resources required to interact with an S3 store.
|
Package s3store contains the resources required to interact with an S3 store. |