schema

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 9 Imported by: 1 module, 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

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

View Source
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

func ParseHash(hash string) (string, error)

ParseHash returns the hash, in lower case, or ErrBadParameter when it isn't a SHA-256 in hexadecimal

func ParseSession

func ParseSession(session string) (*uuid.UUID, error)

ParseSession returns the session, or nil, when it's empty, or ErrBadParameter when it isn't a UUID

func ParseURI

func ParseURI(uri string) (string, error)

ParseURI returns the hash of the resource with the URI, which is resource:///<hash>, or resource://<hash>, as it was before, whose hash was its host. Returns ErrBadParameter when it isn't.

func URI

func URI(hash string) string

URI returns the URI of the resource with the hash, which is resource:///<hash>, whose hash is its path, as it has no host

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

func (r Resource) Cell(col int) tui.CellText

Cell returns the resource's hash, shortened, its name, type, size, session, and when it was last used

func (Resource) Header

func (Resource) Header() []string

Header returns the columns of a resource, as it's listed

func (Resource) Key

func (r Resource) Key() ResourceKey

Key returns the resource's key: its hash, and its session

func (Resource) String

func (r Resource) String() string

func (Resource) URI

func (r Resource) URI() string

URI returns the resource's URI, which is resource://, followed by its content's hash

func (Resource) Width

func (Resource) Width(int) int

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

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

type ResourceKey struct {
	Hash    string
	Session *uuid.UUID
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL