eval

package
v4.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMapping = errors.New("unknown mappings")

ErrMapping is returned by Evaluator when the asked query references a non existing mapping.

View Source
var ErrParser = errors.New("parsing error")

ErrParser is returned by Evaluator when the asked query has invalid syntax.

View Source
var ErrTimeout = errors.New("timeout")

ErrTimeout is returned by Evaluator when the query execution time exceeds the maximum time defined in configuration.

View Source
var ErrValidation = errors.New("validation error")

ErrValidation is returned by Evaluator when the query execution request contains invalid information. • Namespace: is an empty string or is not present • QueryRevisions name: is an empty string or is not present • Revision: is not a positive integer • Tenant: is an empty string or is not present

Functions

func ApplyAggregators

func ApplyAggregators(log restql.Logger, query domain.Query, resources domain.Resources) domain.Resources

ApplyAggregators resolves the `in` keyword in the query, taking values from one statement result than setting it on target statement result.

func ApplyFilters

func ApplyFilters(log restql.Logger, query domain.Query, resources domain.Resources) (domain.Resources, error)

ApplyFilters returns a version of the already resolved Resources only with the fields defined by the `only` clause.

func ApplyHidden

func ApplyHidden(query domain.Query, resources domain.Resources) domain.Resources

ApplyHidden returns a version of the already resolved Resources removing the statement results with the `hidden` clause.

func ResolveVariables

func ResolveVariables(query domain.Query, input restql.QueryInput) domain.Query

ResolveVariables returns a restQL query with all variables resolved to values present in the client body, query parameters or headers, in this specific order.

Types

type Evaluator

type Evaluator struct {
	// contains filtered or unexported fields
}

Evaluator is the interpreter of the restQL language. It can execute saved or ad-hoc queries.

func NewEvaluator

NewEvaluator constructs an instance of the restQL interpreter.

func (Evaluator) AdHocQuery

func (e Evaluator) AdHocQuery(ctx context.Context, queryTxt string, queryOpts restql.QueryOptions, queryInput restql.QueryInput) (domain.Resources, error)

AdHocQuery executes an ad-hoc send by the client with the options and HTTP information.

func (Evaluator) SavedQuery

func (e Evaluator) SavedQuery(ctx context.Context, queryOpts restql.QueryOptions, queryInput restql.QueryInput) (domain.Resources, error)

SavedQuery executes a saved query identified by namespace, id and revision with the options and HTTP information send by the client.

type MappingsReader

type MappingsReader interface {
	FromTenant(ctx context.Context, tenant string) (map[string]restql.Mapping, error)
}

MappingsReader is an interface implemented by types that can fetch a collection of mapping for the given tenant.

type QueryReader

type QueryReader interface {
	Get(ctx context.Context, namespace, id string, revision int) (restql.SavedQuery, error)
}

QueryReader is an interface implemented by types that can fetch a query for the given identification (namespace, id, revision).

Jump to

Keyboard shortcuts

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