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 ErrNotAuthorized // the backend needs its user to sign in, such as to their Google account )
func (Err) HTTP ¶ added in v0.1.2
func (e Err) HTTP() httpresponse.Err
type Filer ¶ added in v0.3.0
type Filer interface {
// 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, and return it, which is at the request's
// path, unless the backend names it, such as a Google task, whose id
// Google gives it
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 first is a rescan of the root, once the
// objects are watched, so a caller which lists them then misses no
// change. 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. A filer which holds resources, such as a client, or a watch, also implements io.Closer, which its owner, such as the registry, calls, rather than those it's given to.
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}, or are its sign-in, such as Google's,
// when it's set
Credentials CredentialProvider
// ClientOpts are the options of the clients of a backend which calls
// other services over HTTP, such as Google's, which it's given as they
// are, such as a user agent, a tracer, of client.OptTracer, a trace, or
// a timeout
ClientOpts []client.ClientOpt
}
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. |
|
google
Package google has filers of Google's services, such as Tasks, whose requests are with the clients of package httpclient, so a request which isn't authorized returns an AuthError, which says a sign-in is needed.
|
Package google has filers of Google's services, such as Tasks, whose requests are with the clients of package httpclient, so a request which isn't authorized returns an AuthError, which says a sign-in is needed. |
|
google/httpclient
Package httpclient has clients of Google's APIs, with go-auth's auth/httpclient, so a request which isn't authorized returns an AuthError, which says a sign-in is needed.
|
Package httpclient has clients of Google's APIs, with go-auth's auth/httpclient, so a request which isn't authorized returns an AuthError, which says a sign-in is needed. |
|
indexer
Package indexer is a filer which wraps another, and keeps an index of its folders, in a Store, which it follows the backend's changes in, so its folder tree is listed from the index, rather than the backend, which can be slow, such as a bucket, or a network mount.
|
Package indexer is a filer which wraps another, and keeps an index of its folders, in a Store, which it follows the backend's changes in, so its folder tree is listed from the index, rather than the backend, which can be slow, such as a bucket, or a network mount. |
|
indexer/memory
Package memory is an index store in memory, for tests, and volumes which are indexed again each time a process starts
|
Package memory is an index store in memory, for tests, and volumes which are indexed again each time a process starts |
|
indexer/pg
Package pg is an index store in a Postgres database, which isn't implemented yet (#72): each of its methods returns ErrNotImplemented
|
Package pg is an index store in a Postgres database, which isn't implemented yet (#72): each of its methods returns ErrNotImplemented |
|
indexer/sqlite
Package sqlite is an index store in a SQLite database, which isn't implemented yet (#71): each of its methods returns ErrNotImplemented
|
Package sqlite is an index store in a SQLite database, which isn't implemented yet (#71): each of its methods returns ErrNotImplemented |
|
indexer/storetest
Package storetest is the conformance tests of an index store, which each store runs, so they behave the same
|
Package storetest is the conformance tests of an index store, which each store runs, so they behave the same |
|
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 |