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.
%% 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).
%% 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)]).
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).
all/1 | Filter the input using multiple filters. |
any/1 | Filter the input using one of multiple filters. |
compile/2 | Compile a query to a module. |
compile/3 | |
compile/4 | |
delete/1 | Release a compiled query. |
eq/2 | |
filter/1 | The number of filtered events for this query module. |
get/2 | |
gt/2 | |
gte/2 | |
handle/2 | Handle an event using a compiled query. |
info/1 | |
input/1 | The number of input events for this query module. |
job_error/1 | The number of job errors for this query module. |
job_input/1 | The number of job inputs for this query module. |
job_run/1 | The number of job runs for this query module. |
job_time/1 | The amount of time jobs took for this query module. |
lt/2 | |
lte/2 | |
neq/2 | |
nf/1 | |
null/1 | Always return true or false . |
output/1 | The number of output events for this query module. |
reset_counters/1 | Reset all counters. |
reset_counters/2 | Reset a specific counter. |
run/3 | |
start/0 | |
union/1 | Return a union of multiple queries. |
wc/1 | |
with/2 | Apply a function to each output of a query. |
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 abadarg
error will be thrown.
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 abadarg
error will be thrown.
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 thedelete/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(Module::atom(), Query::glc_ops:op() | [glc_ops:op()], Reset::boolean()) -> {ok, atom()}
compile(Module, Query, Store, Reset) -> any()
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(Key::atom(), Term::term()) -> glc_ops:op()
filter(Module::atom()) -> non_neg_integer()
The number of filtered events for this query module.
get(Module, Key) -> any()
gt(Key::atom(), Term::term()) -> glc_ops:op()
gte(Key::atom(), Term::term()) -> glc_ops:op()
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 fromgre:make/2
.
info(Module) -> any()
input(Module::atom()) -> non_neg_integer()
The number of input events for this query module.
job_error(Module::atom()) -> non_neg_integer()
The number of job errors for this query module.
job_input(Module::atom()) -> non_neg_integer()
The number of job inputs for this query module.
job_run(Module::atom()) -> non_neg_integer()
The number of job runs for this query module.
job_time(Module::atom()) -> non_neg_integer()
The amount of time jobs took for this query module.
lt(Key::atom(), Term::term()) -> glc_ops:op()
lte(Key::atom(), Term::term()) -> glc_ops:op()
neq(Key::atom(), Term::term()) -> glc_ops:op()
nf(Key::atom()) -> glc_ops:op()
null(Result::boolean()) -> glc_ops:op()
Always return true
or false
.
output(Module::atom()) -> non_neg_integer()
The number of output events for this query module.
reset_counters(Module::atom()) -> ok
Reset all counters
This resets all the counters associated with a modulereset_counters(Module::atom(), Counter::atom()) -> ok
Reset a specific counter
This resets a specific counter associated with a modulerun(Module, Fun, Event) -> any()
start() -> any()
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 isoutput
. If these expectations don't hold
a badarg
error will be thrown.
wc(Key::atom()) -> glc_ops:op()
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 abadarg
error.
Generated by EDoc, May 28 2018, 15:25:56.