eval

package
v4.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRevision  = errors.New("revision must be greater than 0")
	ErrInvalidQueryID   = errors.New("query id must be not empty")
	ErrInvalidNamespace = errors.New("namespace must be not empty")
	ErrInvalidTenant    = errors.New("tenant must be not empty")
)

Validation errors returned be Evaluator

Functions

func ApplyAggregators

func ApplyAggregators(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 MappingError

type MappingError struct {
	Err error
}

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

func (MappingError) Error

func (me MappingError) Error() string

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 ParserError

type ParserError struct {
	Err error
}

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

func (ParserError) Error

func (pe ParserError) Error() string

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).

type TimeoutError

type TimeoutError struct {
	Err error
}

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

func (TimeoutError) Error

func (te TimeoutError) Error() string

type ValidationError

type ValidationError struct {
	Err error
}

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

func (ValidationError) Error

func (ve ValidationError) Error() string

Jump to

Keyboard shortcuts

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