rql

package
v0.0.0-...-2bc12df Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxdepth = 1<<31 - 1

DefaultMaxdepth is the default value of the maxdepth option. It is set to the max value of a 32-bit integer.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASTNode

type ASTNode interface {
	Marshal() interface{}
	Unmarshal(interface{}) error
}

ASTNode represents an AST node in the RQL. Marshal should return an interface{} value that works with ast.MarshalJSON. This would typically be either a map[string]interface{} (JSON object), an []interface{} (JSON array), or a primitive type like nil (null), float64 (number), string, boolean, and time.Time. Similarly, the input in Unmarshal is an interface{} value that was decoded by ast.UnmarshalJSON.

type ActionPredicate

type ActionPredicate interface {
	ASTNode
	EvalAction(plugin.Action) bool
}

ActionPredicate represents a predicate on a Wash action.

type Entry

type Entry struct {
	apitypes.Entry
	Schema *EntrySchema
	// contains filtered or unexported fields
}

Entry represents an RQL entry

func Find

func Find(ctx context.Context, start plugin.Entry, query Query, options Options) ([]Entry, error)

Find returns all descendants of the start entry that satisfy the given query Note that all returned entries' paths will start from "", which represents the start path. For example, if "childOne" and "childTwo" are the cnames of the start entry's children, then their "Path" fields will be set to "childOne" and "childTwo" (where the start entry's path of "" is automatically prefixed).

Each entry's children are descended in lexicographic order (based on their cnames). So given entries "foo", "foo/bar", "foo/baz", "foo/baz/1", the returned entries will be ["foo", "foo/bar", "foo/baz", "foo/baz/1"] (because "bar" comes before "baz").

func (Entry) SchemaKnown

func (e Entry) SchemaKnown() bool

type EntryPredicate

type EntryPredicate interface {
	EvalEntry(Entry) bool
}

EntryPredicate represents a predicate on an entry

type EntrySchema

type EntrySchema = apitypes.EntrySchema

EntrySchema represents an RQL entry's schema

type EntrySchemaPredicate

type EntrySchemaPredicate interface {
	EvalEntrySchema(*EntrySchema) bool
}

EntrySchemaPredicate represents a predicate on an entry schema object

type NumericPredicate

type NumericPredicate interface {
	ASTNode
	EvalNumeric(decimal.Decimal) bool
}

NumericPredicate represents a predicate on a numeric value. The decimal.Decimal type lets us handle arbitrarily large numbers.

type Options

type Options struct {
	// Mindepth is the minimum depth. Descendants at lesser depths are not included
	// in the RQL's returned list of entries.
	//
	// Depth starts from 0. For example, given paths "foo", "foo/bar", "foo/bar/baz",
	// assume "foo" is the start path. Then "foo" is at depth 0, "foo/bar" is at depth 1,
	// "foo/bar/baz" is at depth 2, etc.
	Mindepth int
	// Maxdepth is the maximum depth. Descendants at greater depths are not included
	// in the RQL's returned list of entries. See Mindepth's comments to understand how
	// depth is calculated.
	Maxdepth int
	// Fullmeta is short for "full metadata". If set, then meta primary queries act on
	// the entry's full metadata, and the returned list of entries will include the entry's
	// full metadata. If unset then the RQL uses the partial metadata instead.
	//
	// Note that setting Fullmeta could result in O(N) extra requests to fetch the metadata,
	// where N is the number of visited entries. Using the partial metadata (unsetting Fullmeta)
	// does not result in any extra request.
	Fullmeta bool
}

Options represent the RQL's options

func NewOptions

func NewOptions() Options

NewOptions creates a new Options object

type Primary

type Primary interface {
	ASTNode
	IsPrimary() bool
}

Primary represents the interface implemented by all the primaries

type Query

type Query interface {
	ASTNode
	EntryPredicate
	EntrySchemaPredicate
}

Query represents an RQL query

type StringPredicate

type StringPredicate interface {
	ASTNode
	EvalString(string) bool
}

StringPredicate represents a predicate on a string value

type TimePredicate

type TimePredicate interface {
	ASTNode
	EvalTime(time.Time) bool
}

TimePredicate represents a predicate on a time value.

type ValuePredicate

type ValuePredicate interface {
	ASTNode
	EvalValue(interface{}) bool
	EvalValueSchema(*plugin.JSONSchema) bool
}

ValuePredicate represents a predicate on a metadata (JSON) value

Directories

Path Synopsis
ast

Jump to

Keyboard shortcuts

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