Documentation
¶
Index ¶
- func VolumeName(u *url.URL) string
- type Opt
- type Registry
- func (self *Registry) Add(ctx context.Context, volume string, url *url.URL) (gofiler.Filer, error)
- func (self *Registry) Clone(context.Context, url.Values) (gofiler.Filer, error)
- func (self *Registry) Close() error
- func (self *Registry) CreateObject(ctx context.Context, req schema.CreateObjectRequest) (*schema.Object, error)
- func (self *Registry) Del(ctx context.Context, volume string) error
- func (self *Registry) DeleteObjects(ctx context.Context, req schema.DeleteObjectsRequest) (*schema.DeleteObjectsResponse, error)
- func (self *Registry) GetObject(ctx context.Context, req schema.GetObjectRequest) (*schema.Object, error)
- func (self *Registry) Keys() []string
- func (self *Registry) List(ctx context.Context, req schema.ObjectListRequest) (_ *schema.ObjectList, err error)
- func (self *Registry) ListObjects(ctx context.Context, req schema.ListObjectsRequest) (schema.ListObjectsIterator, error)
- func (self *Registry) ReadObject(ctx context.Context, req schema.GetObjectRequest) (gofiler.ReadObjectFunc, *schema.Object, error)
- func (self *Registry) Run(ctx context.Context, logger *slog.Logger) error
- func (self *Registry) Running() bool
- func (self *Registry) Schemes() []string
- func (self *Registry) URL() *url.URL
- func (self *Registry) Update(ctx context.Context, volume string, patch url.Values) (*schema.Volume, error)
- func (self *Registry) Validate(ctx context.Context, url *url.URL) (*url.URL, error)
- func (self *Registry) Volume(name string) (*schema.Volume, error)
- func (self *Registry) Volumes() []schema.Volume
- func (self *Registry) WatchObjects(ctx context.Context, ch chan<- schema.Event) error
- func (self *Registry) With(ctx context.Context, volume string, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VolumeName ¶
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 ¶
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 ¶
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 WithTracer ¶
WithTracer sets the tracer used for tracing operations.
func WithWorker ¶
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 ¶
func (*Registry) Add ¶
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 ¶
Clone returns ErrNotImplemented, as a registry can't be cloned: its volumes are cloned to change their options, with Update
func (*Registry) Close ¶
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 ¶
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 ¶
func (self *Registry) DeleteObjects(ctx context.Context, req schema.DeleteObjectsRequest) (*schema.DeleteObjectsResponse, error)
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 ¶
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 ¶
func (self *Registry) ListObjects(ctx context.Context, req schema.ListObjectsRequest) (schema.ListObjectsIterator, error)
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 ¶
func (self *Registry) ReadObject(ctx context.Context, req schema.GetObjectRequest) (gofiler.ReadObjectFunc, *schema.Object, error)
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) Schemes ¶
Schemes returns the schemes of the URLs which backends can be created from, in order, such as "file"
func (*Registry) 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 ¶
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 ¶
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 ¶
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 ¶
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.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
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 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 |