Documentation
¶
Overview ¶
Package schema is the types of the objects in a backend, which are the types of the filer's objects
Index ¶
- Constants
- func ASCIIJSON(value string) string
- func EncodeMetaHeader(meta []Meta) (string, error)
- func FormatSize(size int64) string
- func MatchType(object *Object, t string) bool
- func VolumeChange(action changes.ChangeAction, volume *Volume) changes.Change
- func VolumeStateChange(name string) changes.Change
- type Action
- type ActionList
- type Backend
- type Counter
- type CreateObjectRequest
- type DeleteObjectsRequest
- type DeleteObjectsResponse
- type Event
- type EventType
- type GetObjectRequest
- type IndexPhase
- type IndexState
- type IndexStatus
- type ListObjectsIterator
- type ListObjectsRequest
- type Markdown
- type Meta
- type Object
- type ObjectAttr
- type ObjectKey
- type ObjectList
- type ObjectListRequest
- type ObjectMeta
- type ObjectSkipped
- type ObjectUploadResponse
- type Occurrence
- type OffsetLimit
- type Query
- type SearchObject
- type SearchRequest
- type SearchResponse
- type TaskMeta
- type TaskState
- type Volume
- func (v Volume) BareURL() string
- func (v Volume) Cell(col int) tui.CellText
- func (v Volume) Description() string
- func (v Volume) Header() []string
- func (v Volume) IndexStatus() string
- func (v Volume) Options() string
- func (v Volume) Readonly() (bool, error)
- func (v Volume) Status() string
- func (v Volume) String() string
- func (v Volume) Width(col int) int
- type VolumeCreateRequest
- type VolumeIndex
- type VolumeList
- type VolumeMeta
- type VolumePatch
- type When
Constants ¶
const ( StoreChangeSchema = "store" VolumeChangeTable = "volume" )
StoreChangeSchema and VolumeChangeTable are of the changes of a store's volumes, which are published to a go-server broadcaster, whose row is the volume's name, and whose data is the volume, unless it's deleted
const ( // FolderNamespace is the namespace of the metadata of a folder: how // many objects which aren't folders, and how many subfolders, it lists FolderNamespace = "folder" // The keys of a folder's metadata FolderObjectCount = "object-count" FolderSubfolderCount = "subfolder-count" )
const ( OccurrenceEvent = "event" // Of a VEVENT OccurrenceTask = "task" // Of a VTODO, which starts when it's due )
const ( // SchemeFile is the scheme of a volume which is a directory, such as // file://media/mnt/media SchemeFile = "file" // SchemeFS is the scheme of a volume which is a filesystem, but not a // directory, such as fs://media, which a volume can't be added from SchemeFS = "fs" // SchemeS3 is the scheme of a volume which is a bucket, and the prefix of // its objects, such as s3://my-bucket/photos?name=photos SchemeS3 = "s3" )
The schemes of the URLs of volumes' backends
const ActionInputMax = 1 << 20
ActionInputMax is the most bytes of an action's input
const ChangeSchema = "filer"
ChangeSchema is the schema of the changes of a filer's objects, which are published to a go-server broadcaster, whose table is the volume, and whose row is the object's path
const DirectoryType = "inode/directory"
DirectoryType is the type of a directory, as freedesktop.org's shared MIME info has it, which has no content
const MetaHeader = "X-Meta-Data"
MetaHeader is the header of a request which writes a file, or of a part of a form which uploads files, with the user's metadata of the file, as a JSON array of its namespaces, keys and values
const ObjectListLimit = 100
ObjectListLimit is the most objects in a page of a listing, which is the number when the request doesn't set one
const OptDescription = "description"
OptDescription is the option of every backend's URL which describes what the volume is, such as "Folder /mnt/media", which a backend sets, when it isn't set
const RegistryChangeSchema = "registry"
RegistryChangeSchema is of the changes of what a registry knows of a volume, whose table is VolumeChangeTable, and whose row is its name: that it's mounted, or unmounted, or offline, or can't be mounted, or is again, which aren't changes of the store
const SearchLimit = 100
SearchLimit is the most objects of a page of a search, which is the limit, unless a request sets fewer
Variables ¶
This section is empty.
Functions ¶
func ASCIIJSON ¶
ASCIIJSON returns the JSON, with its characters which aren't ASCII, which are only in its strings, escaped, as \uXXXX, or a surrogate pair, and DEL, which isn't a character of a header's value
func EncodeMetaHeader ¶
EncodeMetaHeader returns the user's metadata as the value of MetaHeader, which is a JSON array, which is empty without metadata, whose characters which aren't ASCII are escaped, so it's a header's value
func FormatSize ¶
FormatSize returns a size in bytes, or in KiB, MiB, GiB or TiB, with one decimal place, when it's larger
func MatchType ¶
MatchType returns true when an object is of the type, which is a media type, such as inode/directory, or its major type, such as inode, or its subtype, such as directory, or empty, which every object is. The object's type's parameters, such as charset, are ignored, as is case. A directory is of DirectoryType, when it has no type of its own.
func VolumeChange ¶
func VolumeChange(action changes.ChangeAction, volume *Volume) changes.Change
VolumeChange returns the change of a store's volume: its action, its name as its row, and the volume as its data, unless it's deleted
func VolumeStateChange ¶
VolumeStateChange returns the change of what a registry knows of a volume, of its name, which is read again, as it's an update without data
Types ¶
type Action ¶
type Action struct {
Volume string `json:"volume,omitempty" help:"Name of the volume whose action it is"`
Name string `json:"name" help:"Identifier of the action, such as create_event"`
Title string `json:"title,omitempty" help:"Short label of the action, such as Create event"`
Description string `json:"description,omitempty" help:"What the action does"`
Input json.RawMessage `json:"input,omitempty" help:"JSON schema of the action's input"`
}
Action is something a volume's backend can do, beyond reading and writing its objects, such as creating a calendar event, as it's listed, without running it, whose input's schema is JSON, as a schema of a schema can't be described
type ActionList ¶
type ActionList struct {
Body []Action `json:"body" help:"Actions, in order of their volumes, and their names"`
}
ActionList is the actions of volumes, in order of their volumes' names, and their own
func (ActionList) String ¶
func (a ActionList) String() string
type Backend ¶
type Backend struct {
Scheme string `json:"scheme" help:"Scheme of the URLs of its volumes, such as file"`
Description string `json:"description,omitempty" help:"What it is, such as Server filesystem"`
}
Backend is a type of backend, of the scheme of its volumes' URLs, such as file, and what it is
type Counter ¶
Counter is a listing which can count its objects, of every page, without where it starts after
type CreateObjectRequest ¶
type CreateObjectRequest struct {
ObjectKey
Body io.Reader `json:"-"`
IfNotExists bool // if true, fail with ErrConflict when the object already exists
IfExists bool // if true, fail with ErrPreconditionFailed when the object doesn't exist
ModTime time.Time `json:"last-modified,omitzero"`
ObjectMeta
}
Create an object in the filesystem
type DeleteObjectsRequest ¶
DeleteObjectsRequest deletes an object. A directory is only deleted when Recursive is true, in which case every object beneath it is deleted too.
type DeleteObjectsResponse ¶
type DeleteObjectsResponse struct {
Body []*Object `` /* 131-byte string literal not displayed */
}
DeleteObjectsResponse is the objects which were deleted, which is the object, or the objects beneath a directory, but not directories, unless they're objects of their own, such as a Google Tasks list, rather than there while objects are beneath them
type Event ¶
Event represents a change to an object in the backend.
func ChangeEvent ¶
ChangeEvent returns the event of a change of ChangeSchema, or false when it's of another schema: a change without a row, or whose row ends with "/", is a rescan, of the volume, or of the directory, and a change whose data is {"folder":true} is of a folder, whose path is its key
func Rescan ¶
Rescan returns a rescan of the root of a volume, which WatchObjects sends first, once the objects are watched
func (Event) Change ¶
Change returns the event as a change, of ChangeSchema: its action, the volume as its table, and its path as its row. A rescan is an update, of the volume, without a row, or of a directory, whose row ends with "/", so the objects beneath it are read again, as a broadcaster sends a watcher which misses a change of a volume. A change of a folder, whose path is its key, with a "/" after it, has its path as its row, without it, and the data {"folder":true}.
type EventType ¶
type EventType int
Event types
const ( EventTypeNone EventType = iota // An object which is created, or moved or renamed to the path EventTypeCreated // An object whose content or attributes changed EventTypeUpdated // An object which is deleted, or moved or renamed from the path EventTypeDeleted // A directory whose changes may have been missed, so the objects // beneath it should be compared with what's known about them EventTypeRescan )
type GetObjectRequest ¶
type GetObjectRequest struct {
ObjectKey
IfModifiedSince time.Time `json:"-"` // if non-zero, only return the object if it has been modified since this time
IfNoneMatch []string `json:"-"` // if non-empty, only return the object if its ETag doesn't match any of these
}
Return an object
type IndexPhase ¶
type IndexPhase string
IndexPhase is what a scan of a volume's index is doing
const ( IndexPhaseIdle IndexPhase = "" // It isn't scanned IndexPhaseScanning IndexPhase = "scanning" // Its folders, and files, are listed IndexPhaseIndexing IndexPhase = "indexing" // Its files which are new, or changed, are got, and stored )
The phases of a scan of an index
type IndexState ¶
type IndexState struct {
Status IndexStatus `json:"status,omitempty" help:"How far it's indexed: scanning, or ready, or empty, when it hasn't been yet"`
Folders uint64 `json:"folders,omitempty" help:"How many folders the scan in progress, or the last, has indexed"`
Objects uint64 `` /* 160-byte string literal not displayed */
Mode string `json:"mode,omitempty" help:"What the last scan which finished indexed: folders, or objects"`
Phase IndexPhase `` /* 158-byte string literal not displayed */
Started time.Time `json:"started,omitzero" help:"When the scan in progress, or the last, started"`
Scanned time.Time `json:"scanned,omitzero" help:"When the last scan which finished did"`
Error string `json:"error,omitempty" help:"Why the last scan, or the watch, failed"`
}
IndexState is the state of a volume's index
type IndexStatus ¶
type IndexStatus string
IndexStatus is how far a volume is indexed
const ( IndexStatusNone IndexStatus = "" // It's never been indexed IndexStatusScanning IndexStatus = "scanning" // It's being scanned, for the first time, or again IndexStatusReady IndexStatus = "ready" // It's indexed, and the index follows its changes )
The statuses of an index
type ListObjectsIterator ¶
type ListObjectsIterator interface {
io.Closer
// Next returns the next object, or io.EOF when there are no more objects
Next(context.Context) (*Object, error)
}
Iterates over the objects returned by ListObjects. Caller must close the iterator when done.
type ListObjectsRequest ¶
type ListObjectsRequest struct {
ObjectKey
Recursive bool `json:"recursive,omitempty"`
StartAfter string `json:"start_after,omitempty" help:"Return objects after this path"`
Type string `` /* 158-byte string literal not displayed */
}
ListObjectsRequest lists the objects beneath a path in a volume, which is a directory, or an object, when only it's listed. A path which ends with "/" is a directory, which is listed, even when an object has its name, as it can in a bucket, and which doesn't exist when it's an object.
type Markdown ¶
Markdown is the start of a file's content, as Markdown, such as of a PDF, and where the rest of it starts, when there's more, or zero
type Meta ¶
type Meta struct {
Namespace string `json:"namespace,omitempty"`
Key string `json:"key,omitempty"`
Value json.RawMessage `json:"value,omitempty"`
Text string `json:"text,omitempty"`
}
Meta is a string key-value map for user-defined metadata. Keys should be lowercase for S3 compatibility. Text is the value's text, for people, such as 5s of a duration whose value is 5000000000, when it says more than the value, which is shown in its place.
func DecodeMetaHeader ¶
DecodeMetaHeader returns the user's metadata of the value of MetaHeader, which is a JSON array, which can be empty, but not null, each of which has a key and a value, which is JSON, which can be null
func FolderMeta ¶
FolderMeta returns the metadata of a folder, of how many objects which aren't folders, and how many subfolders, it lists
type Object ¶
type Object struct {
ObjectKey
ObjectMeta
ObjectAttr
Geo []geo.Geometry `` /* 139-byte string literal not displayed */
Events []Occurrence `` /* 126-byte string literal not displayed */
}
Object represents a file or directory in a volume, including its key, metadata, and attributes.
func (Object) NotModified ¶
func (o Object) NotModified(req GetObjectRequest) bool
Key returns the key of the object, which is its path, or for a directory, its path followed by "/", which is the order objects are listed in NotModified returns true when the request's conditions say the object hasn't changed: when its ETag is one of IfNoneMatch, or "*" is, or, when IfNoneMatch is empty, when it hasn't been modified since IfModifiedSince. As in HTTP, IfNoneMatch is used in place of IfModifiedSince when it's set, and times are compared to the second. An object without a modification time, such as a directory, has always been modified.
type ObjectAttr ¶
type ObjectAttr struct {
Size *int64 `json:"size,omitempty"`
ETag *string `json:"etag,omitempty"`
ModTime time.Time `json:"mtime,omitzero"`
IsDir bool `json:"dir,omitempty"`
}
ObjectAttr represents the attributes of an object, which are immutable and cannot be updated.
type ObjectKey ¶
type ObjectKey struct {
Name string `json:"name,omitempty" help:"Volume name"`
Path string `json:"path,omitempty" arg:"" required:"" help:"Object path"`
}
ObjectKey represents the unique identifier of an object, which consists of a volume and a path. The name of the volume isn't used by a backend, which is a single volume, but identifies the volume's backend in the registry.
type ObjectList ¶
type ObjectList struct {
ObjectListRequest
Next string `json:"next,omitempty" help:"Start after this key for the next page"`
Count *uint64 `json:"count" help:"How many objects the listing has, of every page, or null when it isn't known"`
Body []*Object `json:"body"`
}
ObjectList is a page of the objects beneath a path in a volume, in the same order as S3, by their keys. When there are more, Next is the key of the last object, which the next page starts after. Count is how many objects the listing has, of every page, without where it starts after, or its limit, or nil, when its volume can't count them, such as one which isn't indexed.
func (ObjectList) String ¶
func (l ObjectList) String() string
type ObjectListRequest ¶
type ObjectListRequest struct {
ListObjectsRequest
Limit *uint64 `json:"limit,omitempty" help:"Maximum number of objects to return, which defaults to and is capped at 100"`
}
ObjectListRequest lists the objects beneath a path in a volume, a page at a time. The next page starts after the key of the last object of the previous page, which is the list's Next.
func (ObjectListRequest) Query ¶
func (r ObjectListRequest) Query() url.Values
Query returns the query of the request for a page of the objects in a volume, whose name is the path of the request
type ObjectMeta ¶
type ObjectMeta struct {
ContentType string `json:"type,omitempty"`
Meta []Meta `json:"meta,omitempty"`
}
ObjectMeta represents the metadata of an object, which can be updated.
type ObjectSkipped ¶
type ObjectSkipped struct {
Path string `json:"path" help:"Path of the file in the volume"`
Exists bool `json:"exists,omitempty" help:"The file exists, and the upload doesn't overwrite it"`
Reason string `json:"reason" help:"Why the file was skipped"`
}
ObjectSkipped is a file which wasn't uploaded, by its path in the volume, and why, such as it exists, and the upload doesn't overwrite it, or its name isn't stored, such as a hidden file
type ObjectUploadResponse ¶
type ObjectUploadResponse struct {
Body []*Object `json:"body" help:"Files which were written"`
Skipped []ObjectSkipped `json:"skipped,omitempty" help:"Files which weren't written, and why"`
}
ObjectUploadResponse is the files which were uploaded into a directory, in the order they were, and those which were skipped, and why
type Occurrence ¶
type Occurrence struct {
UID string `json:"uid"`
RecurrenceID string `json:"recurrence_id,omitempty"`
Kind string `json:"kind"`
Title string `json:"title,omitempty"`
Start When `json:"start"`
End *When `json:"end,omitempty"` // Exclusive, or nil, of an instant, or a task, which is due
TZ string `json:"tz,omitempty"` // The zone of its times, such as Europe/Berlin, or empty, of an all-day event
}
Occurrence is a time an event, or a task, of a calendar, is: when it starts, and, when it isn't an instant, ends, which are dates, of an all-day event, or times, of its zone, its title, and its UID, and, of an event which repeats, its recurrence id, of when it was to start, which identify it, as an event can be in more than one object, such as a calendar, and an invitation
func (Occurrence) Validate ¶
func (o Occurrence) Validate() error
Validate returns an error when an occurrence has no UID, isn't of an event, or task, has no start, or ends before it starts, or ends with a date, of a time, or a time, of a date
type OffsetLimit ¶
type OffsetLimit struct {
Offset uint64 `json:"offset,omitempty" help:"How many are skipped, before those which are returned"`
Limit *uint64 `json:"limit,omitempty" help:"The most which are returned, or every one, when it isn't set"`
}
OffsetLimit is a page of what's returned: after Offset of them, of at most Limit, or every one, when it's nil, as go-pg's is
type Query ¶
type Query struct {
// Terms are what's searched for, any of which match, each of which is a
// word, or words, which are next to each other, or the start of a word,
// of a term which ends with *
Terms []string `` /* 134-byte string literal not displayed */
// Exclude are terms, as Terms are, which an object which matches
// doesn't, which are of the text's words which start with -, such as
// -symphony, which a query without terms has no use of
Exclude []string `json:"exclude,omitempty" help:"What an object which matches doesn't, such as symphony, of -symphony"`
// Volumes are the volumes which are searched, or every one, without
// any, which isn't of the query's text, as the registry sets it, of the
// volumes which are mounted
Volumes []string `json:"-"`
}
Query is a search of objects, of terms, any of which match an object, of its name, folders and metadata
func (Query) MarshalJSON ¶
MarshalJSON returns the query as a string, of its text
func (Query) MarshalText ¶
MarshalText returns the text of the query, of its terms, between spaces, each of which is quoted, when it has a space, a quote, or a backslash, which are escaped, as a phrase, with * after the quote, of the start of a word, so it's read again, of UnmarshalText, as it is
func (*Query) UnmarshalJSON ¶
UnmarshalJSON reads the query of a string, of its text, or an array of its terms, each of which is a term as it is, or null, which has none
func (*Query) UnmarshalText ¶
UnmarshalText reads the query of text, of its terms, any of which match: each word, which is what's between spaces, such as arvo, or work@example.com, which is one term, a quoted phrase, such as "spiegel im spiegel", and the start of a word, of one which ends with *, such as beethov*, or "arvo pa"*, and those which an object doesn't match, of a word which starts with -, such as -symphony, or -"im spiegel", but not a hyphen within a word, such as Schleswig-Holstein. Returns an error of a quote which doesn't end.
type SearchObject ¶
type SearchObject struct {
Object
Rank float32 `json:"rank" help:"How well it matches, of 0 to 1, which is 1 of the best match"`
}
SearchObject is an object which matches a search, and how well, of 0 to 1, which is 1 of the best of the search's, of every page, so ranks are of the search, rather than of a page
type SearchRequest ¶
type SearchRequest struct {
OffsetLimit
Query Query `json:"query" help:"What's searched for, such as arvo \"spiegel im spiegel\" beethov*"`
}
SearchRequest is a search of the objects of every volume, of its query, which is text, of JSON, and the page of what matches
type SearchResponse ¶
type SearchResponse struct {
SearchRequest
Count uint64 `json:"count" help:"How many objects match, of every page"`
Body []*SearchObject `json:"body"`
}
SearchResponse is a page of the objects which match a search, best first, with their volumes' names, and how many match, of every page
type TaskMeta ¶
type TaskMeta struct {
Meta []Meta
Geo []geo.Geometry
Events []Occurrence
}
TaskMeta is what a task found of an object: its metadata, which a read of it merges with the backend's, the shapes of where it is, and the times of its events
type TaskState ¶
type TaskState struct {
Queued uint64 `json:"queued,omitempty" help:"How many files are queued, or being done, including those which failed, and are tried again"`
Indexed uint64 `` /* 157-byte string literal not displayed */
Failed uint64 `json:"failed,omitempty" help:"How many files it failed of too often, which are given up until they change"`
Error string `json:"error,omitempty" help:"Why it last failed of a file"`
}
TaskState is the work of a task, such as indexing the metadata of files, of a volume's files
type Volume ¶
type Volume struct {
VolumeMeta
Created time.Time `json:"created,omitzero" readonly:"" help:"When the volume was first stored"`
Modified time.Time `json:"modified,omitzero" readonly:"" help:"When the volume's URL, or whether it's enabled, last changed"`
Error string `` /* 199-byte string literal not displayed */
Mounted bool `` /* 158-byte string literal not displayed */
Index *VolumeIndex `json:"index,omitempty" readonly:"" help:"The volume's index, when it's indexed, of its index option, such as index=folders"`
}
Volume is a volume which is registered, or stored
func (Volume) BareURL ¶
BareURL returns the volume's URL without its options, such as file://media/mnt/media, or the URL, when it can't be parsed
func (Volume) Description ¶
Description returns what the volume is, of its URL's description option, or empty, when it hasn't one, or its URL can't be parsed
func (Volume) IndexStatus ¶
IndexStatus returns how the volume's index is: none, when it isn't indexed, or isn't mounted, indexing, when it's scanned, for the first time, with its progress, or again, with the counts of its last scan, or idle, when it's ready, with how many folders it has, or failed, when it hasn't been indexed, with why its last scan, or its watch, failed, when it did
func (Volume) Options ¶
Options returns the options of the volume's URL, other than its description, as key=value, in the order of their keys, separated by spaces, without escaping
func (Volume) Readonly ¶
Readonly returns true when the volume's objects can't be created or deleted, of its URL's readonly option, which is true when it's empty, or there's none. Returns an error when the URL, or the option, can't be parsed.
type VolumeCreateRequest ¶
type VolumeCreateRequest struct {
Name string `json:"name" help:"Volume name"`
URL string `json:"url" help:"URL of the volume's backend, with its options"`
Enabled *bool `json:"enabled,omitempty" help:"Whether the volume is mounted, which it is by default"`
}
VolumeCreateRequest is a volume to create, which is enabled, unless it says it isn't
func (VolumeCreateRequest) Meta ¶
func (r VolumeCreateRequest) Meta() VolumeMeta
Meta returns what's stored of the volume to create
type VolumeIndex ¶
type VolumeIndex struct {
Mode string `json:"mode" help:"What's indexed, such as folders"`
IndexState
Metadata *TaskState `` /* 126-byte string literal not displayed */
Kinds map[string]uint64 `` /* 231-byte string literal not displayed */
}
VolumeIndex is a volume's index: what's indexed, and its state
type VolumeList ¶
type VolumeList struct {
Body []Volume `json:"body" help:"Volumes, in order of their names"`
Backends []Backend `json:"backends" help:"Backends which volumes can be added of, in order of their schemes"`
}
VolumeList is the volumes which are registered, in order of their names, and the backends which volumes can be added of
func (VolumeList) String ¶
func (v VolumeList) String() string
type VolumeMeta ¶
type VolumeMeta struct {
Name string `json:"name" help:"Volume name"`
URL string `json:"url" help:"URL of the volume's backend, with each of its options, defaults too, such as index, but without secrets"`
Enabled bool `json:"enabled" help:"Whether the volume is mounted, when the server starts"`
}
VolumeMeta is what's kept of a volume, so it outlasts a restart: its name, the URL of its backend, which it's added again from, and whether it's mounted when the server starts
type VolumePatch ¶
type VolumePatch map[string]json.RawMessage
VolumePatch is the options of a volume to change, by their keys, as JSON: null removes the option, so it's the default, a list replaces its values, where an empty list has none, and a string, number or boolean replaces its values with the one
func (VolumePatch) Values ¶
func (p VolumePatch) Values() (url.Values, error)
Values returns the options to change, where an option without values is removed, or an error when one isn't null, a list of strings, numbers and booleans, or a string, number or boolean. An empty list is an empty value, so for skip and package, there are none.
type When ¶
When is a date, without a time, of an all-day event, which is midnight, in UTC, of its day, or a time, which is in UTC
func ParseWhen ¶
ParseWhen returns the when of a date, such as 2026-11-20, or a time, such as 2026-11-20T09:00:00Z, of RFC 3339
func (When) MarshalJSON ¶
MarshalJSON returns the when as a string, of a date, or a time
func (When) String ¶
String returns a date as 2026-11-20, or a time as 2026-11-20T09:00:00Z, which sort, as text, as they do in time, of the same kind
func (*When) UnmarshalJSON ¶
UnmarshalJSON reads the when of a string, of a date, or a time