Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPErr ¶ added in v0.1.2
HTTPErr translates an error into an error wrapping a HTTP status code
func ParseURL ¶ added in v0.3.2
ParseURL returns the URL of a volume's backend, which is a URL, such as s3://my.bucket/photos, or otherwise a directory, without a scheme, with any options after a "?", such as /mnt/media?readonly=true, which is made absolute, when it's relative, as the current directory's, and is a file URL, without a host, as its name isn't known, such as file:///mnt/media?readonly=true. On Windows, a directory with a drive, such as C:\media, or C:media, which is relative to the drive's current directory, isn't a URL whose scheme is its drive, and its URL's path has the drive, such as /C:/media. Returns ErrBadParameter, without the value, which can have credentials, when it can't be parsed, and a value with "://" is a URL, not a directory, even when it can't be parsed.
Types ¶
type CreateMode ¶ added in v0.3.0
type CreateMode int
CreateMode is whether a file is created, replaced, or either
const ( CreateOrReplace CreateMode = iota // a file is created, or replaces one which exists CreateOnly // a file which exists isn't replaced ReplaceOnly // a file which doesn't exist isn't created )
type CredentialProvider ¶ added in v0.3.0
type CredentialProvider interface {
// Expand expands the given value using the credential provider, substituting any
// credentials $PLACEHOLDER or ${PLACEHOLDER} as needed.
Expand(ctx context.Context, value string) (string, error)
// Get returns the credential for the key, as JSON
Get(ctx context.Context, key string) (json.RawMessage, error)
// Set stores the credential for the key, which is JSON, replacing any
// credential with the key
Set(ctx context.Context, key string, value json.RawMessage) error
}
type Err ¶ added in v0.1.2
type Err int
Errors
const ( ErrSuccess Err = iota ErrNotFound ErrBadParameter ErrNotImplemented ErrConflict ErrInternalServerError ErrForbidden ErrNotModified ErrCreated // not a failure: the object was created, rather than replaced ErrPreconditionFailed // a condition of the request isn't met, such as replacing an object which doesn't exist ErrUnprocessableContent // the request can't be processed, such as creating an object whose name is skipped )
func (Err) HTTP ¶ added in v0.1.2
func (e Err) HTTP() httpresponse.Err
type Filer ¶ added in v0.3.0
type Filer interface {
io.Closer
// URL returns the filer URL. The scheme, host (bucket/name),
// and path (prefix/directory) identify the storage location. Query
// parameters carry useful non-credential details: region, endpoint, anonymous, readonly, etc.
URL() *url.URL
// Clone returns a new filer of the same storage, with the options of the
// filer, changed by the patch (see PatchValues), which is nil to keep
// them, from what the filer has, rather than its URL, which doesn't have
// its credentials. The filer isn't changed, and the clone is checked as a
// new filer is, such as a bucket being accessible. The registry clones a
// volume's filer to change its options, and to open it again when
// watching it fails.
Clone(context.Context, url.Values) (Filer, error)
// Create object in the filer
CreateObject(context.Context, schema.CreateObjectRequest) (*schema.Object, error)
// Get object metadata from the filer
GetObject(context.Context, schema.GetObjectRequest) (*schema.Object, error)
// Read object content from the filer, by calling the returned function,
// with the object's metadata
ReadObject(context.Context, schema.GetObjectRequest) (ReadObjectFunc, *schema.Object, error)
// List objects in the filer. Call Next on the returned iterator until
// io.EOF is returned. Caller must close the returned iterator.
ListObjects(context.Context, schema.ListObjectsRequest) (schema.ListObjectsIterator, error)
// Delete an object in the filer, and return the deleted object. A
// directory is only deleted when the request is recursive, in which case
// every object beneath it is deleted too. The root of a volume cannot be
// deleted.
DeleteObjects(context.Context, schema.DeleteObjectsRequest) (*schema.DeleteObjectsResponse, error)
// Watch for changes to objects, sending each to the channel, until the
// context is cancelled. The channel isn't closed. It will return
// filer.ErrNotImplemented if the filer backend does not support watching objects.
WatchObjects(context.Context, chan<- schema.Event) error
}
Filer is the interface for storing files and objects.
type Opts ¶ added in v0.3.0
type Opts struct {
// Tracer traces the requests of the backend to other services, such as
// S3, when it's set
Tracer trace.Tracer
// Credentials expand the placeholders of the credentials in the URL of a
// backend, such as ${S3_SECRET}, when it's set
Credentials CredentialProvider
}
Opts are the options of a backend, which the registry passes to it when it's created
type ReadObjectFunc ¶ added in v0.3.0
ReadObjectFunc reads an object's content: it opens the object, calls the function with a reader of the content, and closes the object when the function returns. The reader returns an error once the context is cancelled, or the filer is closed. Returns the function's error, or the error opening or closing the object.
type WriterFS ¶ added in v0.3.0
type WriterFS interface {
fs.StatFS
// Method to create a file in the filesystem from the body, which also
// creates any necessary parent directories. The file is replaced
// atomically: readers see either the previous file or the complete new
// one, and if writing fails the previous file is left unchanged. With
// CreateOnly, an existing file is not replaced, and an error wrapping
// fs.ErrExist is returned. With ReplaceOnly, a file which doesn't exist
// is not created, and an error wrapping fs.ErrNotExist is returned. When
// modtime is not zero, it is set as the modification time of the file.
// Returns the information for the new file.
Create(path string, body io.Reader, mode CreateMode, modtime time.Time) (fs.FileInfo, error)
// Method to delete a file, or a directory and everything beneath it,
// which also removes any empty parent directories. The root directory
// cannot be deleted.
Delete(path string) error
// Release resources held by the filesystem
io.Closer
}
Implement a filesystem which also allows for creating and deleting files
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
filer
command
|
|
|
fs
Package fs provides the filesystem interface for managing objects in directories.
|
Package fs provides the filesystem interface for managing objects in directories. |
|
fs/fsevents
Package fsevents watches a directory, and everything beneath it, for files and directories which are created, updated and deleted, using the efficient mechanism of each platform: FSEvents on macOS, ReadDirectoryChangesW on Windows, and inotify on Linux.
|
Package fsevents watches a directory, and everything beneath it, for files and directories which are created, updated and deleted, using the efficient mechanism of each platform: FSEvents on macOS, ReadDirectoryChangesW on Windows, and inotify on Linux. |
|
s3
Package s3 is a filer of the objects in an S3 bucket, or one which is compatible, beneath a prefix
|
Package s3 is a filer of the objects in an S3 bucket, or one which is compatible, beneath a prefix |
|
s3/seaweedfs
Package seaweedfs watches the changes to the objects of an S3 bucket of a SeaweedFS filer, by subscribing to the changes to the filer's metadata, with its gRPC service
|
Package seaweedfs watches the changes to the objects of an S3 bucket of a SeaweedFS filer, by subscribing to the changes to the filer's metadata, with its gRPC service |
|
schema
Package schema is the types of the objects in a backend, which are the types of the filer's objects
|
Package schema is the types of the objects in a backend, which are the types of the filer's objects |