scope

package
v0.0.0-...-408bc5d Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NULL_EXPLAINER = &NullExplainer{}
)

Functions

func NextId

func NextId() uint64

Types

type AggregatorCtx

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

func NewAggregatorCtx

func NewAggregatorCtx() *AggregatorCtx

func (*AggregatorCtx) Modify

func (self *AggregatorCtx) Modify(name string,
	modifier func(old_value types.Any, pres bool) types.Any) types.Any

type NullExplainer

type NullExplainer struct{}

func (*NullExplainer) Log

func (self *NullExplainer) Log(message string)

func (*NullExplainer) ParseArgs

func (self *NullExplainer) ParseArgs(args *ordereddict.Dict, result interface{}, err error)

func (*NullExplainer) PluginOutput

func (self *NullExplainer) PluginOutput(
	ast_node interface{}, row types.Row)

func (*NullExplainer) RejectRow

func (self *NullExplainer) RejectRow(where_ast_node interface{})

func (*NullExplainer) SelectOutput

func (self *NullExplainer) SelectOutput(row types.Row)

func (*NullExplainer) StartQuery

func (self *NullExplainer) StartQuery(select_ast_node interface{})

type Scope

type Scope struct {
	sync.Mutex
	// contains filtered or unexported fields
}

The scope is a common environment passed to all plugins, functions and operators.

The scope contains all the client specific code which velocifilter will use to actually execute the query. For example, clients may add new plugins (See PluginGeneratorInterface{}), functions (see FunctionInterface{}) or various protocol implementations to the scope prior to evaluating any queries. This is the main mechanism where clients may extend and specialize the VQL language.

The scope also contains convenience functions allowing clients to execute available protocols.

The scope may be populated with free variables that can be referenced by the query.

func NewScope

func NewScope() *Scope

A factory for the default scope. This will add all built in protocols for commonly used code. Clients are expected to add their own specialized protocols, functions and plugins to specialize their scope objects.

func (*Scope) Add

func (self *Scope) Add(a types.Any, b types.Any) types.Any

Add a and b together.

func (*Scope) AddDestructor

func (self *Scope) AddDestructor(fn func()) error

Adding a destructor to the current scope will call it when any parent scopes are closed.

func (*Scope) AddProtocolImpl

func (self *Scope) AddProtocolImpl(implementations ...types.Any) types.Scope

Add various protocol implementations into this scope. Implementations must be one of the supported protocols or this function will panic.

func (*Scope) AppendFunctions

func (self *Scope) AppendFunctions(functions ...types.FunctionInterface) types.Scope

Add client function implementations to the scope. Queries using this scope can call these functions from within VQL queries.

func (*Scope) AppendPlugins

func (self *Scope) AppendPlugins(plugins ...types.PluginGeneratorInterface) types.Scope

Add plugins (data sources) to the scope. VQL queries may select from these newly added plugins.

func (*Scope) AppendVars

func (self *Scope) AppendVars(row types.Row) types.Scope

Append the variables in types.Row to the scope.

func (*Scope) Associative

func (self *Scope) Associative(a types.Any, b types.Any) (types.Any, bool)

Get the field member b from a (i.e. a.b).

func (*Scope) Bool

func (self *Scope) Bool(a types.Any) bool

Evaluate the truth value of a value.

func (*Scope) ChargeOp

func (self *Scope) ChargeOp()

func (*Scope) CheckForOverflow

func (self *Scope) CheckForOverflow() bool

func (*Scope) ClearContext

func (self *Scope) ClearContext()

func (*Scope) Close

func (self *Scope) Close()

Closing a scope will also close all its children. Note that destructors may use the scope so we can not lock it for the duration.

func (*Scope) Copy

func (self *Scope) Copy() types.Scope

func (*Scope) Debug

func (self *Scope) Debug(format string, a ...interface{})

func (*Scope) DecDepth

func (self *Scope) DecDepth()

func (*Scope) Describe

func (self *Scope) Describe(type_map *types.TypeMap) *types.ScopeInformation

func (*Scope) Div

func (self *Scope) Div(a types.Any, b types.Any) types.Any

Divide b into a.

func (*Scope) EnableExplain

func (self *Scope) EnableExplain()

func (*Scope) Eq

func (self *Scope) Eq(a types.Any, b types.Any) bool

Tests two values for equality.

func (*Scope) Error

func (self *Scope) Error(format string, a ...interface{})

func (*Scope) Explainer

func (self *Scope) Explainer() types.Explainer

func (*Scope) GetAggregatorCtx

func (self *Scope) GetAggregatorCtx() types.AggregatorCtx

Get the aggregator context from the scope or one of its parents.

func (*Scope) GetContext

func (self *Scope) GetContext(name string) (types.Any, bool)

func (*Scope) GetDepth

func (self *Scope) GetDepth() int

func (*Scope) GetFunction

func (self *Scope) GetFunction(name string) (types.FunctionInterface, bool)

func (*Scope) GetLogger

func (self *Scope) GetLogger() *log.Logger

func (*Scope) GetMembers

func (self *Scope) GetMembers(a types.Any) []string

func (*Scope) GetPlugin

func (self *Scope) GetPlugin(name string) (types.PluginGeneratorInterface, bool)

func (*Scope) GetSimilarPlugins

func (self *Scope) GetSimilarPlugins(name string) []string

Get a list of similar sounding plugins.

func (*Scope) GetStats

func (self *Scope) GetStats() *types.Stats

func (*Scope) Group

func (self *Scope) Group(
	ctx context.Context, scope types.Scope, actor types.GroupbyActor) <-chan types.Row

func (*Scope) Gt

func (self *Scope) Gt(a types.Any, b types.Any) bool

func (*Scope) IncDepth

func (self *Scope) IncDepth()

func (*Scope) Info

func (self *Scope) Info(type_map *types.TypeMap, name string) (*types.PluginInfo, bool)

func (*Scope) IsClosed

func (self *Scope) IsClosed() bool

func (*Scope) Iterate

func (self *Scope) Iterate(ctx context.Context, a types.Any) <-chan types.Row

func (*Scope) Log

func (self *Scope) Log(format string, a ...interface{})

func (*Scope) Lt

func (self *Scope) Lt(a types.Any, b types.Any) bool

Is a less than b?

func (*Scope) Marshal

func (self *Scope) Marshal(scope types.Scope) (*types.MarshalItem, error)

func (*Scope) Match

func (self *Scope) Match(a types.Any, b types.Any) bool

Does the regex a match object b.

func (*Scope) Materialize

func (self *Scope) Materialize(ctx context.Context,
	name string, query types.StoredQuery) types.StoredQuery

func (*Scope) Membership

func (self *Scope) Membership(a types.Any, b types.Any) bool

Is a a member in b?

func (*Scope) Mul

func (self *Scope) Mul(a types.Any, b types.Any) types.Any

Multiply a and b.

func (*Scope) NewScope

func (self *Scope) NewScope() types.Scope

Create a new scope from this scope.

func (*Scope) PrintVars

func (self *Scope) PrintVars() string

func (*Scope) Resolve

func (self *Scope) Resolve(field string) (interface{}, bool)

Fetch the field from the scope variables.

func (*Scope) SetAggregatorCtx

func (self *Scope) SetAggregatorCtx(ctx types.AggregatorCtx)

func (*Scope) SetContext

func (self *Scope) SetContext(name string, value types.Any)

func (*Scope) SetExplainer

func (self *Scope) SetExplainer(explainer types.Explainer)

func (*Scope) SetGrouper

func (self *Scope) SetGrouper(grouper types.Grouper)

func (*Scope) SetLogger

func (self *Scope) SetLogger(logger *log.Logger)

func (*Scope) SetMaterializer

func (self *Scope) SetMaterializer(materializer types.ScopeMaterializer)

func (*Scope) SetSorter

func (self *Scope) SetSorter(sorter types.Sorter)

func (*Scope) SetThrottler

func (self *Scope) SetThrottler(t types.Throttler)

func (*Scope) SetTracer

func (self *Scope) SetTracer(logger *log.Logger)

func (*Scope) Sort

func (self *Scope) Sort(
	ctx context.Context, scope types.Scope, input <-chan types.Row,
	key string, desc bool) <-chan types.Row

func (*Scope) StackDepth

func (self *Scope) StackDepth() int

func (*Scope) String

func (self *Scope) String() string

func (*Scope) Sub

func (self *Scope) Sub(a types.Any, b types.Any) types.Any

Subtract b from a.

func (*Scope) Trace

func (self *Scope) Trace(format string, a ...interface{})

func (*Scope) Warn

func (self *Scope) Warn(format string, a ...interface{})

type ScopeItems

type ScopeItems struct {
	Vars map[string]*types.MarshalItem `json:"vars,omitempty"`
}

Marshal a scope so it can be restored.

type ScopeUnmarshaller

type ScopeUnmarshaller struct {
	IgnoreVars []string
}

func (ScopeUnmarshaller) Unmarshal

func (self ScopeUnmarshaller) Unmarshal(
	unmarshaller types.Unmarshaller,
	scope types.Scope, item *types.MarshalItem) (interface{}, error)

Jump to

Keyboard shortcuts

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