Documentation
¶
Overview ¶
Package indexpolicy decides how a managed resource is indexed for search (#2111): fully, on its metadata alone, or not at all.
The decision is the writer's first. A writer that says nothing gets the default the operator's rules give the file, matched on its folder path, its media type, its size, its library scope and where the write came from; the first rule that matches decides. A rule may also set a ceiling, so a writer cannot ask for more indexing than the operator allows on a folder of bulk data. Being written by a script is never itself the deciding fact: poster art a pipeline writes is searchable, and an origin is only a matcher an operator may choose to use.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New(`must be one of "full", "metadata", "none"`)
ErrInvalid is returned for a policy value that is none of the three.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Default is the policy a resource no rule decides gets. Empty is full.
Default string `yaml:"default,omitempty"`
// Rules are matched in order; the first that sets an index decides the
// default, and the first that sets a max caps a writer's request.
Rules []Rule `yaml:"rules,omitempty"`
}
Config is the resources.index section.
type Decision ¶
Decision is a resolved policy and whether the writer chose it. A policy no writer chose is the one a later reclassification may change.
type Origin ¶
type Origin string
Origin is where a resource write came from, a matcher a rule may use.
const ( // OriginUpload is a person uploading through the portal or the REST API. OriginUpload Origin = "upload" // OriginAgent is a session's manage_resource call. OriginAgent Origin = "agent" // OriginScript is any write made while a managed script runs. OriginScript Origin = "script" // OriginExport is an export tool's output landed in the library. OriginExport Origin = "export" // OriginWebhook is an inbound webhook source's compacted window. OriginWebhook Origin = "webhook" )
The writers a resource can come from.
type Policy ¶
type Policy string
Policy is how one resource is indexed for search.
The three policies, cheapest last. Full embeds the resource's metadata and a prefix of its content and stores that prefix for the lexical arm; Metadata embeds the name, description, folder, filename and tags and reads no content; None enqueues no index job, reads no blob, stores no text and no vector.
func Parse ¶
Parse reads a policy a writer or an operator named. Empty is not a policy; callers treat it as "not said".
func (Policy) ReadsContent ¶
ReadsContent reports whether a resource under p has its content extracted.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver applies a validated Config.
func Default ¶
func Default() *Resolver
Default returns a resolver with no operator rules: the built-in rules over a full default. A deployment that configures nothing gets it.
func NewResolver ¶
NewResolver builds a resolver over cfg, validating it. The built-in rules follow cfg's own.
type Rule ¶
type Rule struct {
// Path is a slash glob over the resource's folder path, where "**"
// matches any number of folders: "pipelines/**" is everything filed under
// pipelines, at any depth.
Path string `yaml:"path,omitempty"`
// MIME lists media types, each exact or a family ("image/*").
MIME []string `yaml:"mime,omitempty"`
// SizeOver matches a file larger than this ("1MiB", "500KB", or bytes).
SizeOver string `yaml:"size_over,omitempty"`
// Scope matches the library: global, persona or user.
Scope string `yaml:"scope,omitempty"`
// Origin lists the writers the rule applies to.
Origin []string `yaml:"origin,omitempty"`
// Index is the policy a writer that says nothing gets. Empty leaves the
// default to the next rule, so a rule may set only a ceiling.
Index string `yaml:"index,omitempty"`
// Max is the most indexing a writer may ask for here. Empty is no ceiling.
Max string `yaml:"max,omitempty"`
// contains filtered or unexported fields
}
Rule is one operator rule. Every matcher it sets must hold for the rule to apply; a rule that sets none applies to every resource.
func BuiltinRules ¶
func BuiltinRules() []Rule
BuiltinRules are the rules that follow an operator's own: a table of values is embedded on its metadata alone, which is what #1988 did in code. An operator rule that matches first decides instead.