Documentation
¶
Index ¶
- func ActionOf(action Action) schema.Action
- func HTTPErr(err error) error
- func PatchValues(values, patch url.Values) url.Values
- func ValidActionName(name string) bool
- type Action
- type ArtworkStore
- type Backend
- type CacheEntry
- type CacheMeta
- type CacheStore
- type Err
- type Filer
- type Icon
- type Opts
- type ReadObjectFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActionOf ¶ added in v0.5.0
ActionOf returns what an action is, without running it, as it's listed, such as over HTTP
func HTTPErr ¶ added in v0.1.2
HTTPErr translates an error into an error wrapping a HTTP status code
func PatchValues ¶ added in v0.3.0
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
func ValidActionName ¶ added in v0.5.0
ValidActionName returns true when the name of an action is valid: of letters, digits, "_" and "-", of up to 64 characters, as a tool's name is
Types ¶
type Action ¶ added in v0.5.0
type Action interface {
// Name is the action's identifier, in snake_case, such as create_event,
// which is a tool's name as it is (see ValidActionName)
Name() string
// Title is a short label of the action, such as "Create event"
Title() string
// Description is what the action does, for people and models
Description() string
// Input is the JSON schema of the action's input
Input() *jsonschema.Schema
// Run does the action, with its input, which is JSON of its schema, and
// returns the object it created or changed
Run(ctx context.Context, input json.RawMessage) (*schema.Object, error)
}
Action is something a backend can do, beyond reading and writing its objects, such as creating a calendar event, which a Filer returns of Actions. It maps onto an LLM tool: its name, description and input are a tool's, and the object it returns is the tool's result.
type ArtworkStore ¶ added in v0.6.0
type ArtworkStore interface {
// SetObjectArtwork stores the artwork, or gets the artwork of each one's
// hash, which is stored already, and links the object of the volume of
// the key to it, replacing its links, in one transaction, and returns
// it, without its data, in the order of its contexts, or removes its
// links, with none. Returns ErrNotFound when the object isn't stored,
// ErrBadParameter when artwork isn't valid, or two are of the same
// context, and ErrConflict when the artwork of a hash, which is stored
// already, has another type, or size. An object's links are removed
// when it's deleted, or changes, of its entity tag, size or
// modification time, as a task's metadata of it is.
SetObjectArtwork(ctx context.Context, volume, key string, artwork ...schema.ArtworkMeta) ([]*schema.Artwork, error)
// GetArtwork returns the artwork of the hash, with its data, when it's
// asked for, or ErrNotFound
GetArtwork(ctx context.Context, hash string, data bool) (*schema.Artwork, error)
// ObjectArtwork returns the artwork the object of the volume of the key
// links to, without its data, in the order of its contexts, which is
// none when it links to none, or isn't stored
ObjectArtwork(ctx context.Context, volume, key string) ([]*schema.Artwork, error)
// UnlinkVolumeArtwork removes the links of the objects of the volume to
// their artwork, but not what tasks found of them, otherwise, such as
// when its files aren't enriched with artwork any more, whose artwork
// is deleted once no object links to it (see DeleteUnlinkedArtwork)
UnlinkVolumeArtwork(ctx context.Context, volume string) error
// DeleteUnlinkedArtwork deletes the artwork which no object links to,
// such as of objects which changed, or were deleted, and returns how
// many were deleted
DeleteUnlinkedArtwork(ctx context.Context) (int, error)
}
ArtworkStore keeps artwork: images, such as an album's cover, or a thumbnail, of their type, size and context, by the hash of their context and data, which objects of volumes' indexes link to, so artwork is kept once, however many objects link to it, and an object links to artwork of one context once, at most. Artwork is stored as it's linked to, in one transaction, so artwork is never stored, but not linked to, meanwhile.
type Backend ¶ added in v0.5.2
type Backend interface {
// Scheme returns the scheme of the URLs of its volumes, such as file, in
// lower case, of two characters or more
Scheme() string
// Description returns what it is, such as "Server filesystem", rather
// than what one of its volumes is, which is the filer's Description
Description() string
// Icon returns the image which represents it, or nil, when it has none
Icon() Icon
// Defaults returns the options of a volume which aren't set, as a URL's
// query, such as readonly=true, which a volume's URL has, unless they're
// set, apart from those of each volume, such as its name, or
// description
Defaults() url.Values
// New opens the volume of the URL, of its options, apart from the
// registry's, such as index, with the volume's cache, which the backend
// uses, or not, and the options every backend is created with: the
// tracer, the provider of credentials, and the client options. A volume's
// name is its URL's name option, or its host. A backend which holds
// resources implements io.Closer, which its owner calls.
New(ctx context.Context, u *url.URL, cache CacheStore, opts Opts) (Filer, error)
}
Backend is a kind of volume, such as a directory, or a bucket, of the scheme of its URLs, which describes itself, and opens a volume of a URL. Each backend's package returns its own, of its Backend function, such as fs.Backend(), so a backend of another package, or program, is added to the registry as one which is built in is.
type CacheEntry ¶ added in v0.5.2
type CacheEntry interface {
io.ReadSeekCloser
io.ReaderAt
// Meta returns what the entry is of
Meta() CacheMeta
// Size returns how many bytes the content is
Size() int64
// Stored returns when it was stored
Stored() time.Time
// Expires returns when it isn't returned, or zero, without a TTL
Expires() time.Time
}
CacheEntry is an entry's content, which can seek, and be read at an offset, as a file can, and what it is
type CacheMeta ¶ added in v0.5.2
type CacheMeta struct {
Version string `json:"version,omitempty"` // Such as a revision, an entity tag, or a page token
Values map[string]string `json:"values,omitempty"` // Small values, such as a feed's Last-Modified
}
CacheMeta is what an entry is of
type CacheStore ¶ added in v0.5.2
type CacheStore interface {
// Get returns the entry of the key, or ErrNotFound when there's none, or
// it expired. The caller closes it.
Get(ctx context.Context, key string) (CacheEntry, error)
// Put stores the content, as it's read, as the entry of the key, with its
// metadata, for the TTL, or until it's replaced, or deleted, when it's
// zero, replacing any, once it's all read, and returns it, to read back,
// which the caller closes. When the content can't be read, any entry of
// the key is kept.
Put(ctx context.Context, key string, ttl time.Duration, meta CacheMeta, r io.Reader) (CacheEntry, error)
// GetOrCreate is how a backend caches something it fetches, such as a
// Google Doc it exports: it returns the cached entry of the key when
// that's of the version the backend wants, so it isn't fetched again,
// and otherwise fetches it, by calling valuefn, which writes the content
// to w, as it's fetched, and stores it, for the TTL. The entry's
// metadata is what valuefn returns, with the version, unless valuefn
// sets another. When several callers ask for a key at once, valuefn is
// called once, and the others wait for it, so a key is fetched once.
// The caller closes the entry which is returned.
GetOrCreate(ctx context.Context, key, version string, ttl time.Duration, valuefn func(w io.Writer) (CacheMeta, error)) (CacheEntry, error)
// Delete deletes the entry of the key, or every entry beneath it, when it
// ends with "/", such as "export/", which isn't an error when there's
// none. An entry which is being read is deleted once it's closed.
Delete(ctx context.Context, key string) error
}
CacheStore keeps what a volume's backend gets from a service, by key, on disk. An entry is kept for its TTL, or until it's replaced, or deleted, or the volume changes, when the registry deletes the store. A backend gets its volume's store as an argument, which it uses, or not, and must work without any of its entries, so an entry is never the only copy of anything. It's safe to use from more than one goroutine.
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
// Description returns what the volume is, such as "Folder /mnt/media",
// or "S3 bucket photos in eu-west-1", which is its URL's description
// option, when it's set, and is otherwise the backend's of it
Description() string
// Actions returns what the backend can do, beyond reading and writing
// its objects, such as creating a calendar event, or nil, such as for a
// filesystem, whose objects are all it has
Actions() []Action
// 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 Icon ¶ added in v0.5.2
type Icon interface {
// Type returns the media type of the image, such as image/svg+xml
Type() string
// Data returns the image
Data() []byte
}
Icon is an image which represents something, such as a backend: its media type, such as image/svg+xml, and its data
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 are the server's, which a backend looks up of the names in
// its URL, such as S3_SECRET, or are its sign-in, such as Google's, when
// it's set
Credentials credential.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.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
backend
|
|
|
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. |
|
internal/blocks
Package blocks reads a file at offsets, of the blocks of it which are requested, the last of which are kept, so a parser's reads, which are scattered across a file, such as a PDF's objects, are of few requests
|
Package blocks reads a file at offsets, of the blocks of it which are requested, the last of which are kept, so a parser's reads, which are scattered across a file, such as a PDF's objects, are of few requests |
|
internal/icon
Package icon is the icons of the backends, which are their images, of their media types, such as an SVG image a backend embeds
|
Package icon is the icons of the backends, which are their images, of their media types, such as an SVG image a backend embeds |
|
rss
Package rss is a backend of an RSS feed, of rss://<name>/<host>/<path>, whose items are files, of their days, /YYYY/YYYY-MM/DD-<title>.html, each an HTML page of the item, with its title, author, date and link as its metadata, and its enclosure, such as a podcast's episode, too.
|
Package rss is a backend of an RSS feed, of rss://<name>/<host>/<path>, whose items are files, of their days, /YYYY/YYYY-MM/DD-<title>.html, each an HTML page of the item, with its title, author, date and link as its metadata, and its enclosure, such as a podcast's episode, too. |
|
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 |
|
webcal
Package webcal is a backend of an iCalendar feed, which a calendar is subscribed to, of webcal://<name>/<host>/<path>, whose events are files, of their days, /YYYY/YYYY-MM/DD-<title>.ics, each an iCalendar of the event, with its changes to the times it repeats.
|
Package webcal is a backend of an iCalendar feed, which a calendar is subscribed to, of webcal://<name>/<host>/<path>, whose events are files, of their days, /YYYY/YYYY-MM/DD-<title>.ics, each an iCalendar of the event, with its changes to the times it repeats. |
|
cmd
|
|
|
filer
command
|
|
|
Package frontend is go-filer's web UI: its modules, such as Files, which the package @mutablelogic/go-filer exports, and the server's app, which make builds into app/dist, and which a command built with the "frontend" tag embeds, as EmbedFS.
|
Package frontend is go-filer's web UI: its modules, such as Files, which the package @mutablelogic/go-filer exports, and the server's app, which make builds into app/dist, and which a command built with the "frontend" tag embeds, as EmbedFS. |
|
cmd
Package cmd serves the web UI, and the server's configuration, which it reads, beside the API, when the server is built with the "frontend" tag, which embeds the UI, once it's built, with npm, into frontend/app/dist, which make does.
|
Package cmd serves the web UI, and the server's configuration, which it reads, beside the API, when the server is built with the "frontend" tag, which embeds the UI, once it's built, with npm, into frontend/app/dist, which make does. |
|
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. |
|
Package metadata is the task which enriches the files of a volume which is indexed with index=metadata, with their metadata, of go-metadata: tags of audio and video, EXIF of photos, the titles of documents, movies and TV episodes on TMDB, recordings on AcoustID, and so on.
|
Package metadata is the task which enriches the files of a volume which is indexed with index=metadata, with their metadata, of go-metadata: tags of audio and video, EXIF of photos, the titles of documents, movies and TV episodes on TMDB, recordings on AcoustID, and so on. |
|
cmd
Package cmd is the flags of the metadata enrichment of a server, which it embeds, and composes into the registry of its volumes
|
Package cmd is the flags of the metadata enrichment of a server, which it embeds, and composes into the registry of its volumes |
|
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 |
|
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 a store of volumes, and their indexes, in a SQLite database, which is created when it doesn't exist, or in memory, of sqlite.Memory, such as for tests
|
Package sqlite is a store of volumes, and their indexes, in a SQLite database, which is created when it doesn't exist, or in memory, of sqlite.Memory, such as for tests |
|
sqlite/schema
Package schema is the schema of the SQLite store: its tables, its queries, and the types which are read from, and written to, them
|
Package schema is the schema of the SQLite store: its tables, its queries, and the types which are read from, and written to, them |
|
test
Package test is the conformance tests of an index store, which each store runs, so they behave the same
|
Package test is the conformance tests of an index store, which each store runs, so they behave the same |

