filer

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 16 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-filer

Go Reference Test

A filer stores the objects in a volume. Each backend implements filer.Filer, and must behave the same way, so that a volume can be stored on a filesystem or in S3 without clients seeing a difference. The semantics follow S3, and the filesystem backend emulates S3 where they differ.

Packages

Package Description
github.com/mutablelogic/go-filer The Filer interface, the WriterFS interface of a writable filesystem, and the errors
github.com/mutablelogic/go-filer/filer The registry of the volumes' backends, which are created from URLs, such as file://media/mnt/media, and watched
github.com/mutablelogic/go-filer/filer/schema The objects, requests and events
github.com/mutablelogic/go-filer/filer/fs The filesystem backend, for any fs.FS, and writable for a directory
github.com/mutablelogic/go-filer/filer/fs/fsevents Watches a directory for changes, on macOS, Linux and Windows. It has no dependencies on the other packages
github.com/mutablelogic/go-filer/filer/google Backends of Google's services: Google Tasks and Google Contacts
github.com/mutablelogic/go-filer/filer/google/httpclient Clients of Google's APIs, with go-auth's auth/httpclient, so a request which isn't authorized is an AuthError
github.com/mutablelogic/go-filer/filer/indexer A filer which wraps a backend, and keeps an index of its folders in a Store, which follows its changes
github.com/mutablelogic/go-filer/filer/indexer/memory An index store in memory
github.com/mutablelogic/go-filer/filer/indexer/storetest The conformance tests every index store runs

Usage

fs.New returns a writable filer for a directory, and fs.NewFS returns a filer for any fs.FS, which is read-only unless it implements filer.WriterFS. Either can be made read-only with the readonly option, when creating and deleting objects is filer.ErrForbidden. The filer takes ownership of the filesystem, and closes it when it's closed. filer.Filer has no Close: a filer which holds resources, as these do, implements io.Closer, which its owner calls, rather than the code it's given to.

import (
    "context"
    "fmt"
    "io"
    "os"

    gofiler "github.com/mutablelogic/go-filer"
    filerfs "github.com/mutablelogic/go-filer/filer/fs"
    schema "github.com/mutablelogic/go-filer/filer/schema"
)

func main() {
    ctx := context.Background()

    // A writable filer for the directory, named "media"
    filer, err := filerfs.New("media", "/mnt/media", nil, gofiler.Opts{})
    if err != nil {
        panic(err)
    }
    defer filer.Close()

    // Read an object, within the function returned
    read, obj, err := filer.ReadObject(ctx, schema.GetObjectRequest{
        ObjectKey: schema.ObjectKey{Path: "/music/song.mp3"},
    })
    if err != nil {
        panic(err)
    }
    fmt.Println(obj.ContentType, *obj.Size)
    if err := read(ctx, func(r io.Reader) error {
        _, err := io.Copy(os.Stdout, r)
        return err
    }); err != nil {
        panic(err)
    }
}

ReadObject returns the object, and a function which reads its content: the file is opened when the function is called, the content is read within the function passed to it, and the file is closed when that returns. Nothing is opened when the function isn't called. The file isn't read, and filer.ErrPreconditionFailed is returned, when it changed after the object was returned.

Closing the filer stops listings, reads, writes and watches which are in progress, which return fs.ErrClosed. The list iterator can be used from more than one goroutine.

Options

The options of the filesystem backend are passed to New and NewFS as url.Values, and are the query parameters of the filer's URL, fs://<name>, which has each of them, defaults too, so it says how the filer is set up. They're followed by the options of a backend, gofiler.Opts, which every backend is created with, of the registry's WithTracer, WithCredentials and WithClientOpts, whose Tracer traces each operation, such as fs.ListObjects, with the volume and path, when it's set. Each option can be repeated, and setting one replaces its defaults, so an empty value, such as skip=, sets none.

Option Description Default
skip A regular expression of the names of files and directories which aren't objects, nor is anything in a directory with the name Hidden files, starting with ., and those which operating systems and applications leave alongside content, such as Thumbs.db, desktop.ini, Icon\r, Microsoft Office owner files (~$*) and backup files (*~)
package A regular expression of the names of directories which are packages (?i)\.bundle$ and (?i)\.sparsebundle$
readonly Whether objects can only be read, and not created or deleted, even when the filesystem is writable: true, false, or empty, which is true. A filesystem which isn't writable is read-only whatever it's set to false

An unknown option, an expression which doesn't compile, or a readonly which isn't a boolean, is filer.ErrBadParameter.

Google Tasks

google.NewTaskFiler returns a filer of a person's Google Tasks:

  • Lists are directories, named by their ids, such as /MTA3NjI, with their titles as metadata, as task:title and dc:title, and folder:children and folder:children-count, whether they have tasks, and how many. The API doesn't count them, so they're read: one request a list, for each 100 tasks.
  • Tasks are iCalendar files, text/calendar; component=VTODO, named by their ids, such as /MTA3NjI/Q2xvdWQ.ics, so a path stays the same when a task is renamed.
  • Content: one VTODO, which calendar and task apps can import: the task's id as its UID, its title, notes, due date, status, completion, parent as RELATED-TO, URL, and update time.
  • Metadata: task:title, status, due, completed and parent, and what iCalendar can't have, task:hidden, of a completed task cleared from its list, and task:links, such as to the email a task was created from.
  • Writing: a volume with readonly=false, which asks for write access when its user signs in, writes a task as an iCalendar of one VTODO:
    • Creating: PUT /LIST/~new.ics creates a task, beneath its RELATED-TO, when it has one, and returns it at its path, of the id Google gives it, as ~ is never in one.
    • Updating: PUT of a task's path replaces its title, notes, due date and status, clearing those the VTODO doesn't have, and moves it, when its RELATED-TO changes. Its other fields, such as its links, are kept. Its UID, when it has one, must be the task's id, and a task which doesn't exist isn't found, as its id can't be chosen.
    • Deleting: a task, with its subtasks, as Google does, or a list, with its tasks, with recursive, which returns the list too, after its tasks, as it's an object of its own.
    • Watching: what the volume writes, or deletes, is sent to its watches straight away, rather than when they refresh.

To set it up, with the filer command, store the OAuth client, a desktop app's, which Google's console downloads, as the server's credential, and create a volume, which signs in with Google, in the browser:

filer credential-set GOOGLE_CLIENT --json < client_secret.json
filer volume-create-gtasks tasks

In the registry, its URL is gtasks://<name>, such as gtasks://tasks?readonly=false, and its sign-in is of the registry's credentials (filer.WithCredentials):

filer, err := google.NewTaskFiler(ctx, "tasks", url.Values{"readonly": {"true"}}, gofiler.Opts{Credentials: credentials, ClientOpts: clientopts})
  • GOOGLE_CLIENT: the credential of the OAuth client, a desktop app's, as the JSON of its client_id and client_secret, or the file Google's console downloads for it.
  • GOOGLE_TOKEN: the credential of the user's sign-in, a go-auth Grant, or another, of the credential parameter. It must be for GOOGLE_CLIENT's client, and have the tasks.readonly or tasks scope, or tasks, when it isn't read-only. Its token is refreshed, with the client's secret, and stored again, when it expires.
  • Signing in: when there's no sign-in, or it's for another client, or doesn't have the scopes, or is revoked, it's go-auth's SignInError, with how to sign in: Google's server, the client's ID, the scopes, and the credential. The HTTP API returns it as 401, with its detail, without the client's secret.
  • Options: a backend's gofiler.Opts: its Credentials, of the sign-in, and its ClientOpts, go-client's, as they are, such as a user agent, a tracer, of client.OptTracer, or a trace.
  • readonly: true by default. With false, tasks can be created, updated and deleted, and lists deleted, as under Writing above.
  • quota: the most requests a minute, spaced evenly, which is 120 by default, or 0 for no limit.
  • refresh_interval: how often WatchObjects polls for changes, which is a minute by default, or 0 not to watch.
  • hidden: include tasks which are hidden, as they're completed, and cleared from their list, which are left out unless it's true.

Google Contacts

google.NewContactFiler returns a filer of a person's Google Contacts, of the People API, with the same Google sign-in as Google Tasks, which asks for the contacts.readonly scope, keeping the scopes it has, so one sign-in can have both:

  • Contacts are vCard files, text/vcard, at the root, named by their ids, such as /c123.vcf, with dc:title and contact:name, of their names.
  • Content: written with go-metadata's pkg/vcard: names, nicknames, emails, phones, URLs, addresses, organisations, titles, birthday, notes, a photo, as a link, but not Google's default one, of initials, and when it was updated, as REV. A primary value is preferred.
  • No birthdays as objects, nor calendars, only contacts.
  • Options: quota, refresh_interval and credential, as Google Tasks has. It's read-only, so far: readonly=false isn't implemented.
  • Watching polls the contacts' entity tags, at the refresh interval.

In the registry, its URL is gcontacts://<name>, and the filer command creates one with volume-create-gcontacts, signing in with Google, in the browser, when it needs to.

Indexer

indexer.New(name, backend, store) returns a filer of a backend whose folders are indexed, in a Store, 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.

  • Run(ctx) indexes it, until the context is cancelled. It watches the backend, and scans it once it's watching, a folder at a time, so a change during the scan isn't missed.
  • Following changes: a rescan event scans that folder again. A folder which is created, or deleted, is indexed, or removed, with what's beneath it.
  • Backends which can't be watched, such as a bucket without SeaweedFS, are scanned again at the rescan interval, 15 minutes by default (WithRescanInterval).
  • A watch which fails is watched, and scanned, again after a while, which doubles each time, up to a minute. Why it failed is in the state.
  • ListFolders lists a folder's folders, or every folder beneath it, with Recursive, in the order a backend lists them. GetObject of a folder is the index's, with folder:children and folder:children-count. Until the first scan finishes, both are the backend's.
  • Writes and deletes through it update the index as they're made.
  • Everything else, such as files, is the backend's. Files are indexed later.
  • State is the index's status (never indexed, scanning, or ready), how many folders the scan has indexed, when it started and finished, and why it last failed.
  • Stores: indexer/memory so far. SQLite and Postgres stores come next, and every store passes indexer/storetest.

In the registry, filer.WithIndexerStore(store) lets volumes be indexed, of their index option:

  • index=folders indexes a volume's folders, and index=none, or no option, doesn't. The registry takes it off the URL before the backend sees it.
  • Running: the registry runs each indexer until the volume is removed. Its watchers get the backend's changes through the indexer, so the backend is watched once.
  • Update turns it on, or off, which removes the index, and keeps it through other changes.
  • Del removes the volume's index.
  • The volume has index, with its mode, status, folders scanned, and last error, and its URL has index=folders, or index=none, when it isn't indexed.
  • Listing folders: ListObjects with Type inode/directory, inode, or directory, which is GET /object/{name}?type=directory, or filer objects --type directory, lists an indexed volume's folders from its index, once it's ready. A listing of a type is filtered for every volume.
  • The filer server keeps its indexes in memory, so they're scanned again when it starts.

Object Model

  • An object is a file, identified by its path within the volume, which starts with /. The root of the volume is /.
  • A directory exists when an object exists beneath it. Directories have no size or modification time, and their content type is inode/directory.
  • The key of a file is its path, and the key of a directory is its path followed by /. Listings are in the byte order of keys, as in S3.
  • Empty parent directories are removed by the filesystem backend when an object is deleted, as an S3 prefix with no objects beneath it does not exist.
  • Files which are not regular files, such as sockets, named pipes and devices, are not objects, nor are symbolic links which are broken, or lead outside the volume.
  • Files and directories whose names are skipped (see skip) are not objects, and can't be created.
  • A package, such as a macOS sparse disk image, is a directory which is an object, as Finder shows it as one file. It has a modification time, and the content type of its extension, but no size, and can't be read. The files in it are not objects, and are deleted with it.
  • Paths which aren't valid fs.FS paths, with //, . or .. elements, or a trailing /, are fs.ErrInvalid.
  • The content type of an object is from its extension, as sniffing the content would mean reading it.

Operations

Operation Filesystem S3
Clone with options Open the directory again, at its path Create a client again, and check the bucket with HeadBucket, with the credentials, which the URL doesn't have
GetObject of a file stat HeadObject
GetObject of a directory stat HeadObject returns 404, then ListObjectsV2 with Prefix="dir/" and MaxKeys=1 to check the directory exists
GetObject with IfModifiedSince or IfNoneMatch filer.ErrNotModified when it hasn't changed, to the second, or its ETag, or *, matches. IfNoneMatch is used in place of IfModifiedSince when it's set HeadObject with IfModifiedSince or IfNoneMatch, which returns 304
ReadObject open, checking the file hasn't changed GetObject, with IfMatch of the ETag returned
CreateObject Write a hidden temporary file, then rename it over the object, so it's replaced atomically PutObject, or a multipart upload
CreateObject with IfNotExists Link the temporary file to the object, which fails when it exists PutObject with If-None-Match: *
CreateObject with IfExists Check the object exists, then rename over it PutObject with If-Match of the ETag of the object
ListObjects Walk the directory, in key order ListObjectsV2 with Delimiter="/", or no delimiter when recursive. Directories are the CommonPrefixes
ListObjects with StartAfter Seek within each directory StartAfter, dropping a CommonPrefix equal to it
ListObjects of a missing path 404 An empty listing, so an extra request is needed to return 404
DeleteObjects of a file remove HeadObject for the metadata, and to return 404 as DeleteObject succeeds for missing keys, then DeleteObject
DeleteObjects of a directory RemoveAll. Returns the files deleted, including hidden files List the prefix, then DeleteObjects in batches of 1000. Returns the keys deleted
Remove empty parent directories After each delete Not needed, as empty prefixes do not exist
WatchObjects Watch the directory (see Watching) Subscribe to the changes to a SeaweedFS filer's metadata, with the seaweedfs-filer-grpc option, and otherwise filer.ErrNotImplemented, as S3's event notifications need a queue

Object metadata isn't stored yet, so CreateObject with metadata is filer.ErrNotImplemented.

Watching

WatchObjects sends each change to an object to a channel, until the context is cancelled or the filer is closed. The first change is a rescan of the root, once the objects are watched, so a caller which lists them then misses no change. A change is an object which is created, updated or deleted, or a directory which should be rescanned, as its changes may have been missed. Changes to files which aren't objects aren't sent, and a change within a package is an update to the package.

Directories are watched with the fsevents package, using the efficient mechanism of each platform:

Platform Mechanism
macOS FSEvents, which needs cgo
Linux inotify
Windows ReadDirectoryChangesW

On other platforms, and on macOS without cgo, and for a filer of a filesystem which isn't a directory, WatchObjects returns filer.ErrNotImplemented.

The registry of volumes is watched by its Run, which watches each volume when it's added, or updated, until it's removed, and publishes their changes to go-server's broadcaster, as changes of the filer schema, whose table is the volume, and whose row is the object's path, until its context is cancelled, when it closes the registry: it removes and closes the volumes, cancelling the calls to With which are using them, and the registry can't be used again. It's closed only by Run, so it should be run while the registry is used, as the server does. The broadcaster is set with filer.WithBroadcaster, and its owner runs and serves it, such as a server, which can share it with its other modules. The server command creates one, served as /changes, unless it's given one. Without a broadcaster, the changes aren't published. Registry.WatchObjects watches the broadcaster, and converts the changes back to events. Without it, the volumes aren't watched. It holds a change to an object until the object is quiet for 250ms (filer.WithDebounce), or at most two seconds, and merges its changes, so an object which changes many times, such as a file which is written in parts, is one change, one which is created and deleted isn't one, and one which is deleted and created again is updated. A watcher isn't held up by the others, so when it's slow to receive the changes, the broadcaster drops a volume's changes, and sends it a rescan of the volume, once it can receive it, which is an update without a row. With a meter (filer.WithMeter), Run counts the changes in filer.events, a counter whose attributes are the worker, filer.worker, which is the hostname, or filer.WithWorker's name, the volume, filer.volume, and the change, filer.event.type, such as created, which the meter's provider pushes to the metrics server.

Modification Time

The modification time of an object is stored in the x-amz-meta-mtime metadata of an S3 object, which is used in preference to LastModified. LastModified is the time the object was uploaded, and cannot be set, so it is only used when the metadata is not set. Its value is seconds since the Unix epoch, with an optional fraction of a second, such as 1764569708.5, as rclone and s3fs write it, so the times they write are read too. It isn't part of an object's user metadata, so mtime can't be a key of it, outside a namespace.

ListObjectsV2 does not return metadata, so a listing from S3 has the LastModified time, which can differ from the modification time returned by GetObject.

Differences

These cannot be made identical, and are known differences between the backends:

  • Keys. S3 allows keys which cannot be represented as paths, such as those containing //, . or .. elements, \ or :, or a trailing /, and a file and a directory with the same name, such as a and a/b. The S3 backend skips these keys in listings, so that they are not objects, in the same way as hidden files.
  • Directory markers. Zero-byte objects whose keys end in / are created by the S3 console and some tools to represent directories. They are not objects, and are skipped in listings.
  • Atomicity. Deleting a directory in S3 takes several requests, and can fail part of the way through. Deleting a directory on the filesystem is not atomic either.
  • ETag. S3 returns an ETag for each object. The filesystem backend does not set it, so only IfNoneMatch: * matches.
  • Packages. S3 has no packages, so a package's files are objects in S3.

Errors

Errors are converted to HTTP errors by filer.HTTPErr. The filesystem backend returns filer errors, and fs errors, such as fs.ErrNotExist:

Error HTTP status
fs.ErrNotExist, filer.ErrNotFound 404
fs.ErrInvalid, filer.ErrBadParameter 400
fs.ErrExist, filer.ErrConflict 409
fs.ErrPermission, filer.ErrForbidden 403
fs.ErrClosed, filer.ErrServiceUnavailable 503
filer.ErrNotModified 304
filer.ErrPreconditionFailed 412
filer.ErrUnprocessableContent 422
filer.ErrNotImplemented 501

The S3 backend converts S3 errors in the same way:

S3 error Error HTTP status
NoSuchKey, NoSuchBucket fs.ErrNotExist 404
AccessDenied filer.ErrForbidden 403
SlowDown, ServiceUnavailable filer.ErrServiceUnavailable 503
PreconditionFailed filer.ErrPreconditionFailed 412

Development

The packages are vetted and tested with make, with GOWORK=off:

Target Description
make test Vet, then run the tests, and their coverage, in build/coverage.txt
make vet Vet the packages for macOS, Linux, Windows and FreeBSD
make race-test Run the tests with the race detector, which needs cgo
make tidy Tidy the module
make clean Remove build/

The test workflow vets the packages, and runs the race tests on Linux, macOS and Windows, for pull requests and pushes to main.

make builds the filer server with the store of its indexes chosen by INDEXER_BACKEND, as the build tag indexer_<backend>:

  • sqlite, the default, is a SQLite database, <name>-index.db, such as filer-index.db, in the user's cache folder.
  • memory keeps them in memory, so volumes are scanned again when the server starts.
  • pg is a Postgres database, of go-pg's flags, --pg.url and --pg.password, or PG_URL and PG_PASSWORD.

The SQLite and Postgres stores aren't implemented yet (#71, #72), so their volumes' indexes fail with ErrNotImplemented, until they are. make INDEXER_BACKEND=memory indexes volumes now.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPErr added in v0.1.2

func HTTPErr(err error) error

HTTPErr translates an error into an error wrapping a HTTP status code

func ParseURL added in v0.3.2

func ParseURL(value string) (*url.URL, error)

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.

func PatchValues added in v0.3.0

func PatchValues(values, patch url.Values) url.Values

PatchValues returns a copy of the options, changed by the patch: each key of the patch replaces the option's values with its own, or, when it has none, removes the option, so it's the default

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
	ErrServiceUnavailable
	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) Error added in v0.1.2

func (e Err) Error() string

func (Err) HTTP added in v0.1.2

func (e Err) HTTP() httpresponse.Err

func (Err) With added in v0.1.2

func (e Err) With(args ...any) error

func (Err) Withf added in v0.1.2

func (e Err) Withf(format string, args ...any) error

Withf returns an error wrapping the error code, with a formatted message. As with fmt.Errorf, the format may use %w to wrap errors, so that they can still be matched with errors.Is and errors.As.

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

type ReadObjectFunc func(context.Context, func(io.Reader) error) error

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
cmd
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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL