Module glc

Event filter implementation.

Description

Event filter implementation.

An event query is constructed using the built in operators exported from this module. The filtering operators are used to specify which events should be included in the output of the query. The default output action is to copy all events matching the input filters associated with a query to the output. This makes it possible to construct and compose multiple queries at runtime.

Examples of built in filters

  %% Select all events where 'a' exists and is greater than 0.
  glc:gt(a, 0).
  %% Select all events where 'a' exists and is equal to 0.
  glc:eq(a, 0).
  %% Select all events where 'a' exists and is not equal to 0.
  glc:neq(a, 0).
  %% Select all events where 'a' exists and is less than 0.
  glc:lt(a, 0).
  %% Select all events where 'a' exists and is anything.
  glc:wc(a).
 
  %% Select no input events. Used as black hole query.
  glc:null(false).
  %% Select all input events. Used as passthrough query.
  glc:null(true).

Examples of combining filters

  %% Select all events where both 'a' and 'b' exists and are greater than 0.
  glc:all([glc:gt(a, 0), glc:gt(b, 0)]).
  %% Select all events where 'a' or 'b' exists and are greater than 0.
  glc:any([glc:gt(a, 0), glc:gt(b, 0)]).

Handling output events

Once a query has been composed it is possible to override the output action with an erlang function. The function will be applied to each output event from the query. The return value from the function will be ignored.

  %% Write all input events as info reports to the error logger.
  glc:with(glc:null(true), fun(E) ->
      error_logger:info_report(gre:pairs(E)) end).

Function Index

all/1Filter the input using multiple filters.
any/1Filter the input using one of multiple filters.
compile/2Compile a query to a module.
compile/3
compile/4
delete/1Release a compiled query.
eq/2
filter/1The number of filtered events for this query module.
get/2
gt/2
gte/2
handle/2Handle an event using a compiled query.
info/1
input/1The number of input events for this query module.
job_error/1The number of job errors for this query module.
job_input/1The number of job inputs for this query module.
job_run/1The number of job runs for this query module.
job_time/1The amount of time jobs took for this query module.
lt/2
lte/2
neq/2
nf/1
null/1Always return true or false.
output/1The number of output events for this query module.
reset_counters/1Reset all counters.
reset_counters/2Reset a specific counter.
run/3
start/0
union/1Return a union of multiple queries.
wc/1
with/2Apply a function to each output of a query.

Function Details

all/1

all(Filters::[glc_ops:op()]) -> glc_ops:op()

Filter the input using multiple filters.

For an input to be considered valid output the all filters specified in the list must hold for the input event. The list is expected to be a non-empty list. If the list of filters is an empty list a badarg error will be thrown.

any/1

any(Filters::[glc_ops:op()]) -> glc_ops:op()

Filter the input using one of multiple filters.

For an input to be considered valid output on of the filters specified in the list must hold for the input event. The list is expected to be a non-empty list. If the list of filters is an empty list a badarg error will be thrown.

compile/2

compile(Module::atom(), Query::glc_ops:op() | [glc_ops:op()]) -> {ok, atom()}

Compile a query to a module.

On success the module representing the query is returned. The module and data associated with the query must be released using the delete/1 function. The name of the query module is expected to be unique. The counters are reset by default, unless Reset is set to false

compile/3

compile(Module::atom(), Query::glc_ops:op() | [glc_ops:op()], Reset::boolean()) -> {ok, atom()}

compile/4

compile(Module, Query, Store, Reset) -> any()

delete/1

delete(Module::atom()) -> ok

Release a compiled query.

This releases all resources allocated by a compiled query. The query name is expected to be associated with an existing query module. Calling this function will shutdown all relevant processes and purge/delete the module.

eq/2

eq(Key::atom(), Term::term()) -> glc_ops:op()

filter/1

filter(Module::atom()) -> non_neg_integer()

The number of filtered events for this query module.

get/2

get(Module, Key) -> any()

gt/2

gt(Key::atom(), Term::term()) -> glc_ops:op()

gte/2

gte(Key::atom(), Term::term()) -> glc_ops:op()

handle/2

handle(Module::atom(), Event::[{atom(), term()}] | gre:event()) -> ok

Handle an event using a compiled query.

The input event is expected to have been returned from gre:make/2.

info/1

info(Module) -> any()

input/1

input(Module::atom()) -> non_neg_integer()

The number of input events for this query module.

job_error/1

job_error(Module::atom()) -> non_neg_integer()

The number of job errors for this query module.

job_input/1

job_input(Module::atom()) -> non_neg_integer()

The number of job inputs for this query module.

job_run/1

job_run(Module::atom()) -> non_neg_integer()

The number of job runs for this query module.

job_time/1

job_time(Module::atom()) -> non_neg_integer()

The amount of time jobs took for this query module.

lt/2

lt(Key::atom(), Term::term()) -> glc_ops:op()

lte/2

lte(Key::atom(), Term::term()) -> glc_ops:op()

neq/2

neq(Key::atom(), Term::term()) -> glc_ops:op()

nf/1

nf(Key::atom()) -> glc_ops:op()

null/1

null(Result::boolean()) -> glc_ops:op()

Always return true or false.

output/1

output(Module::atom()) -> non_neg_integer()

The number of output events for this query module.

reset_counters/1

reset_counters(Module::atom()) -> ok

Reset all counters

This resets all the counters associated with a module

reset_counters/2

reset_counters(Module::atom(), Counter::atom()) -> ok

Reset a specific counter

This resets a specific counter associated with a module

run/3

run(Module, Fun, Event) -> any()

start/0

start() -> any()

union/1

union(Queries::[glc_ops:op()]) -> glc_ops:op()

Return a union of multiple queries.

The union of multiple queries is the equivalent of executing multiple queries separately on the same input event. The advantage is that filter conditions that are common to all or some of the queries only need to be tested once.

All queries are expected to be valid and have an output action other than the default which is output. If these expectations don't hold a badarg error will be thrown.

wc/1

wc(Key::atom()) -> glc_ops:op()

with/2

with(Query::glc_ops:op(), Action::fun((gre:event()) -> term())) -> glc_ops:op()

Apply a function to each output of a query.

Updating the output action of a query finalizes it. Attempting to use a finalized query to construct a new query will result in a badarg error.


Generated by EDoc, May 28 2018, 15:25:56.