jq

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEvaluationTimeout signals that evaluating a query exceeded the
	// evaluation timeout.
	ErrEvaluationTimeout = errors.New("query evaluation timed out")
)

Evaluation errors.

Functions

func QueryCompiler

func QueryCompiler(rawQuery string) (*gojq.Code, error)

QueryCompiler converts raw query strings into compiled queries.

Types

type CachedCompiler

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

CachedCompiler wraps a compiler with an LRU cache.

func NewCachedCompiler

func NewCachedCompiler(compiler Compiler, size int) (*CachedCompiler, error)

NewCachedCompiler returns a new LRU-caching compiler of given cache size.

func (*CachedCompiler) Compiler

func (c *CachedCompiler) Compiler(rawQuery string) (*gojq.Code, error)

Compiler looks up the rawQuery in the cache. If found, it returns the precompiled query. Otherwise, it compiles rawQuery, and caches the result.

type Compiler

type Compiler = func(string) (*gojq.Code, error)

Compiler compiles raw queries.

type Evaluator

type Evaluator interface {
	Evaluate(string, interface{}) ([]interface{}, error)
}

Evaluator evaluates jq queries.

type QueryEvaluationError

type QueryEvaluationError struct {
	Err error
}

QueryEvaluationError signals that a query was malformed.

func (*QueryEvaluationError) Error

func (e *QueryEvaluationError) Error() string

Error returns the wrapped error message.

type QueryEvaluator

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

QueryEvaluator compiles queries and evaluates JSON input.

func NewQueryEvaluator

func NewQueryEvaluator(compiler Compiler) *QueryEvaluator

NewQueryEvaluator returns a new QueryEvaluator using compiler.

func (*QueryEvaluator) Evaluate

func (e *QueryEvaluator) Evaluate(rawQuery string, input interface{}) ([]interface{}, error)

Evaluate compiles the raw query string rawQuery and evaluates input. It returns a slice of evaluation results. If the query fails to compile, or input fails to evaluate, it errors.

type TimeoutEvaluator

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

TimeoutEvaluator wraps an evaluator and sets a timeout on its execution.

func NewTimeoutEvaluator

func NewTimeoutEvaluator(evaluator Evaluator, timeout time.Duration) *TimeoutEvaluator

NewTimeoutEvaluator returns a new evaluator with a timeout on its execution.

func (*TimeoutEvaluator) Evaluate

func (e *TimeoutEvaluator) Evaluate(rawQuery string, input interface{}) ([]interface{}, error)

Evaluate evaluates a raw query, erroring if a time limit is exceeded.

Jump to

Keyboard shortcuts

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