filer

package
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: 29 Imported by: 0 modules, 0 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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VolumeName

func VolumeName(u *url.URL) string

VolumeName returns the name of the volume of a URL, which is its name option, when it's set, such as s3://my.bucket/?name=photos, or otherwise its host, such as file://media/mnt/media or s3://photos/, or empty, when it has neither

Types

type Opt

type Opt func(*opt) error

Opt is a functional option of the registry

func WithBroadcaster added in v0.4.0

func WithBroadcaster(b *broadcaster.Broadcaster) Opt

WithBroadcaster sets the broadcaster which Run publishes the changes to the volumes to, which its owner runs, and serves, such as a server, which can share it with its other modules. Without it, the changes aren't published, and WatchObjects is ErrNotImplemented.

func WithClientOpts

func WithClientOpts(clientopts ...client.ClientOpt) Opt

WithClientOpts sets the client options of the backends which call other services over HTTP, such as Google's, which they're given as they are, such as a user agent, a tracer, of client.OptTracer, a trace, or a timeout, as a command's are, of server.Cmd's ClientEndpoint. The registry doesn't add its own tracer to them, so a request isn't traced twice, or left out of a trace it's given.

func WithCredentials

func WithCredentials(credentials gofiler.CredentialProvider) Opt

WithCredentials sets the provider of the credentials of the backends, which expands the placeholders of the credentials in their URLs, such as ${S3_SECRET}, so the URLs don't have the credentials

func WithDebounce

func WithDebounce(delay time.Duration) Opt

WithDebounce sets how long a change to an object is held, until it's quiet for it, when its changes are merged, so an object which changes many times, such as a file which is written in parts, is one change, which is 250ms by default, or zero to send the changes at once. A change is held for at most two seconds, or the delay, when it's longer.

func WithIndexerStore added in v0.4.0

func WithIndexerStore(store indexer.Store) Opt

WithIndexerStore sets the store of the indexes of volumes, which a volume with the index option, such as index=folders, is indexed in, by the volume's name. Without it, a volume can't be indexed.

func WithMeter

func WithMeter(meter metric.Meter) Opt

WithMeter sets the OpenTelemetry meter used for metrics.

func WithTracer

func WithTracer(tracer trace.Tracer) Opt

WithTracer sets the tracer of the backends' operations, such as fs's, and S3's

func WithWorker

func WithWorker(name string) Opt

WithWorker sets the name of the worker, such as the server's, which is in the metrics, so those of the workers are told apart, and which is the hostname by default

type Registry

type Registry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, opts ...Opt) (*Registry, error)

New creates a registry of the backends of volumes

func (*Registry) Add

func (self *Registry) Add(ctx context.Context, volume string, url *url.URL) (gofiler.Filer, error)

Add a backend to the registry for the specified volume, created from the URL, and return it. The volume is watched until it's removed, and its changes are sent to the calls to WatchObjects. Returns an error if a backend already exists for the volume, or is being added, or the URL does not name the volume. The registry isn't locked while the backend is created, which is cancelled when ctx is.

func (*Registry) Clone

func (self *Registry) Clone(context.Context, url.Values) (gofiler.Filer, error)

Clone returns ErrNotImplemented, as a registry can't be cloned: its volumes are cloned to change their options, with Update

func (*Registry) CreateObject

func (self *Registry) CreateObject(ctx context.Context, req schema.CreateObjectRequest) (*schema.Object, error)

CreateObject creates an object in the volume named by the request

func (*Registry) Del

func (self *Registry) Del(ctx context.Context, volume string) error

Del removes the backend for the specified volume from the registry, and closes it once any calls to With which are using it have returned, which are cancelled, and it's no longer watched. It can't be used once Del is called, but stays registered until it's closed, so a volume which isn't registered has released what it used, such as its directory. Del waits until the backend is closed, or ctx is cancelled. Returns ErrConflict, and doesn't remove it, when it's called from a function passed to With which is using the volume, which it'd wait for. Does nothing if there is no backend for the volume, or it's being added.

func (*Registry) DeleteObjects

DeleteObjects deletes an object, or the objects beneath a directory, in the volume named by the request

func (*Registry) GetObject

func (self *Registry) GetObject(ctx context.Context, req schema.GetObjectRequest) (*schema.Object, error)

GetObject returns an object in the volume named by the request

func (*Registry) Keys

func (self *Registry) Keys() []string

Keys returns the volumes which are registered, and can be used, in order, which doesn't include those which are being added or removed

func (*Registry) List

func (self *Registry) List(ctx context.Context, req schema.ObjectListRequest) (_ *schema.ObjectList, err error)

List returns a page of the objects beneath a path in the volume named by the request, of at most its limit, which defaults to and is capped at schema.ObjectListLimit. When there are more, Next is the key of the last object, which the next page starts after, with StartAfter.

func (*Registry) ListObjects

ListObjects lists the objects in the volume named by the request. The volume's backend isn't closed until the iterator is closed, or the volume is removed, when the iterator is closed, and returns fs.ErrClosed.

func (*Registry) ReadObject

ReadObject returns an object in the volume named by the request, and a function which reads its content, which keeps the volume's backend from being closed while it reads, and is cancelled when the volume is removed. Returns ErrNotFound from the function when the volume was removed, or added again, since the object was returned.

func (*Registry) Run

func (self *Registry) Run(ctx context.Context, logger *slog.Logger) (err error)

Run watches the volumes, and publishes their changes, until the context is cancelled, when it stops watching them, and closes the registry: it removes and closes the volumes, cancelling and waiting for the calls to With which are using them, and returns their errors. The registry can't be used, or run, once it's closed, which is fs.ErrClosed.

func (*Registry) Running

func (self *Registry) Running() bool

Running returns true when Run is running

func (*Registry) Schemes

func (self *Registry) Schemes() []string

Schemes returns the schemes of the URLs which backends can be created from, in order, such as "file"

func (*Registry) URL

func (self *Registry) URL() *url.URL

URL returns the URL of the registry, which is filer:, as it's the filer of every volume, whose URLs are those of their backends

func (*Registry) Update

func (self *Registry) Update(ctx context.Context, volume string, patch url.Values) (*schema.Volume, error)

Update changes the options of a volume, which are the query of the URL of its backend, and returns it. 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 (see gofiler.PatchValues). The backend is cloned with the options first, which checks them, so a volume isn't changed when they're invalid, or would rename it. Then the volume's backend is closed, as Del closes it, waiting for the calls to With which are using it, and the clone is registered in its place. Its name is kept while it's closed, so it isn't added by another call. Returns ErrNotImplemented when the backend can't be cloned, such as a filesystem which isn't a directory, ErrNotFound when the volume isn't registered, or is being added or removed, and ErrConflict when it's called from a function passed to With which is using the volume, which it'd wait for.

func (*Registry) Validate

func (self *Registry) Validate(ctx context.Context, url *url.URL) (*url.URL, error)

Validate returns the URL of a backend, after checking a backend can be created from it, which is then closed. The URL is the backend's, with each of its options, defaults too, which a backend can be added from.

func (*Registry) Volume

func (self *Registry) Volume(name string) (*schema.Volume, error)

Volume returns the volume, which is registered, and can be used, with the URL of its backend, or ErrNotFound when it isn't registered, or is being added or removed

func (*Registry) Volumes

func (self *Registry) Volumes() []schema.Volume

Volumes returns the volumes which are registered, and can be used, in order of their names, with the URLs of their backends

func (*Registry) WatchObjects

func (self *Registry) WatchObjects(ctx context.Context, ch chan<- schema.Event) error

WatchObjects sends each change to the objects of every volume to the channel, of the broadcaster's changes, until the context is cancelled. A call which falls behind is sent a rescan of each volume it missed a change of. Returns ErrNotImplemented without a broadcaster, as the changes aren't published, and fs.ErrClosed when the registry is closed, or the broadcaster stops running.

func (*Registry) With

func (self *Registry) With(ctx context.Context, volume string, fn func(context.Context, gofiler.Filer) error) error

With calls fn with the backend for the specified volume, or returns an error if the volume is not registered. The backend is not closed until fn returns, so fn must finish using the backend before it returns. The context passed to fn is cancelled when ctx is cancelled, or when the volume is removed, so that long-running operations do not delay removing it. The registry is not locked while fn runs, so fn may call other registry methods, but Del or Update of its own volume, with the context passed to it, is ErrConflict, as they'd wait for fn to return.

Directories

Path Synopsis
fs
Package fs provides the filesystem interface for managing objects in directories.
Package fs provides the filesystem interface for managing objects in directories.
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.
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.
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.
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.
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
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
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
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
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
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