filer

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 23 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 WithClientOpts

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

WithClientOpts sets the client options of the backends which call other services over HTTP

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 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 used for tracing operations.

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) Close

func (self *Registry) Close() error

Close removes and closes all the backends, cancelling and waiting for any calls to With which are using them, and stopping watching them, and waiting for those which Del is closing. Calls to WatchObjects return, and backends cannot be added after the registry is closed. Close can't be called from a function passed to With, as it would wait for the function to return.

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, except when it's called from a function passed to With, which uses the backend, when it returns once the backend can't be used, and the backend is closed once the function returns. 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) error

Run processes events on the runloop, until the context is cancelled

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 would 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 the options which aren't the defaults, 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

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, including Del for the volume, with the context passed to it, but not Close.

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