Documentation
¶
Overview ¶
Package schema has the resources' schema: a resource's content, which is kept once, by its hash, and what it is, such as its name and type, which a session can have, or which is on its own
Index ¶
- Constants
- func ParseHash(hash string) (string, error)
- func ParseSession(session string) (*uuid.UUID, error)
- func ParseURI(uri string) (string, error)
- func URI(hash string) string
- type Resource
- type ResourceContentRequest
- type ResourceCreateRequest
- type ResourceEvent
- type ResourceKey
- type ResourceList
- type ResourceListRequest
- type ResourceMeta
- type ResourceRequest
Constants ¶
const ( // Scheme is the scheme of a resource's URI, which is resource://, // followed by its content's hash Scheme = "resource" // Name is the schema of the resources' events Name = "resource" // ResourceTable is the table of the events of the resources, whose rows // are their hashes ResourceTable = "resource" // DefaultRetention is how long a resource on its own is kept, after it // was last used, before it's deleted DefaultRetention = 24 * time.Hour // CleanInterval is how often the resources which aren't needed, and the // content no resource refers to, are deleted CleanInterval = time.Hour // DefaultMaxSize is the largest content of a resource, in bytes DefaultMaxSize = 256 << 20 // DefaultListLimit is the most resources which are listed, unless the // request says otherwise, and MaxListLimit the most which can be DefaultListLimit = 100 MaxListLimit = 1000 )
Variables ¶
This section is empty.
Functions ¶
func ParseHash ¶
ParseHash returns the hash, in lower case, or ErrBadParameter when it isn't a SHA-256 in hexadecimal
func ParseSession ¶
ParseSession returns the session, or nil, when it's empty, or ErrBadParameter when it isn't a UUID
Types ¶
type Resource ¶
type Resource struct {
Hash string `` /* 195-byte string literal not displayed */
Size int64 `json:"size" readonly:"" help:"Size of the resource's content, in bytes" example:"1024"`
Created time.Time `json:"created,omitzero" readonly:"" help:"When the resource was created"`
Used time.Time `json:"used,omitzero" readonly:"" help:"When the resource was last created, or its content read"`
ResourceMeta
}
Resource is a resource: its content's hash, which, with its session, identifies it, the size of its content, when it was created, and last used, and what it is. Resources with the same content, in different sessions, have the one content.
func (Resource) Cell ¶
Cell returns the resource's hash, shortened, its name, type, size, session, and when it was last used
func (Resource) Key ¶
func (r Resource) Key() ResourceKey
Key returns the resource's key: its hash, and its session
type ResourceContentRequest ¶
type ResourceContentRequest struct {
ResourceRequest
Download bool `` /* 146-byte string literal not displayed */
}
ResourceContentRequest is the resource whose content is read, and whether it's downloaded, as an attachment, which the browser saves, rather than shown in it
type ResourceCreateRequest ¶
type ResourceCreateRequest struct {
Session string `` /* 145-byte string literal not displayed */
Name string `` /* 127-byte string literal not displayed */
Description string `json:"description,omitempty" help:"Description of the resource" optional:""`
Type string `` /* 176-byte string literal not displayed */
}
ResourceCreateRequest is what a resource which is created is, as the query parameters of its upload, or its form's values
func (ResourceCreateRequest) Meta ¶
func (r ResourceCreateRequest) Meta() (ResourceMeta, error)
Meta returns what the resource which is created is. Returns ErrBadParameter when the session isn't a UUID.
func (ResourceCreateRequest) Query ¶
func (r ResourceCreateRequest) Query() url.Values
Query returns the request as the parameters of a URL's query
type ResourceEvent ¶
type ResourceEvent struct {
Session string `json:"session,omitempty"`
}
ResourceEvent is the data of an event of a resource, which is created, or deleted: the session it's in, or none
type ResourceKey ¶
ResourceKey identifies a resource: its content's hash, and its session, or none, for a resource on its own
func (ResourceKey) String ¶
func (k ResourceKey) String() string
String returns the key, as its hash, and its session, when it has one
type ResourceList ¶
type ResourceList struct {
ResourceListRequest
Count uint `json:"count" help:"How many resources there are"`
Body []Resource `json:"body,omitempty" help:"The resources"`
}
ResourceList is the resources which are listed, the most recently used first, and how many there are
func (ResourceList) String ¶
func (r ResourceList) String() string
type ResourceListRequest ¶
type ResourceListRequest struct {
Session string `` /* 167-byte string literal not displayed */
Offset uint `json:"offset,omitempty" help:"Resources to skip" example:"0" optional:""`
Limit *uint `json:"limit,omitempty" help:"Most resources to return" example:"10" optional:""`
}
ResourceListRequest is a request to list the resources of a session, or those on their own, from the offset, and at most the limit of them
func (ResourceListRequest) Query ¶
func (r ResourceListRequest) Query() url.Values
Query returns the request as the parameters of a URL's query
type ResourceMeta ¶
type ResourceMeta struct {
Name string `json:"name,omitempty" help:"Name of the resource, such as its file's name" example:"report.pdf" optional:""`
Description string `json:"description,omitempty" help:"Description of the resource" example:"The quarterly report" optional:""`
Type string `` /* 161-byte string literal not displayed */
Session *uuid.UUID `` /* 186-byte string literal not displayed */
}
ResourceMeta is what a resource is: its name, such as a file's, its description, its type, and the session it's in, or none, for a resource on its own
type ResourceRequest ¶
type ResourceRequest struct {
Session string `json:"session,omitempty" format:"uuid" help:"Session the resource is in, or none, for a resource on its own" optional:""`
}
ResourceRequest is the session of a resource, which is a query parameter of its requests, or none, for a resource on its own
func (ResourceRequest) Key ¶
func (r ResourceRequest) Key(hash string) (ResourceKey, error)
Key returns the key of the resource with the hash, in the request's session, or on its own. Returns ErrBadParameter when the hash isn't a SHA-256 in hexadecimal, or the session isn't a UUID.
func (ResourceRequest) Query ¶
func (r ResourceRequest) Query() url.Values
Query returns the request as the parameters of a URL's query