diff --git a/README.org b/README.org index 9511729..a4fe2f0 100644 --- a/README.org +++ b/README.org @@ -22,12 +22,12 @@ Goldrush is a small Erlang app that provides fast event stream processing with an erlang function. The function will be applied to each output event from the query. -# Usage # +* Usage To use goldrush in your application, you need to define it as a rebar dep or include it in erlang's path. -Before composing modules, you'll need to define a query. The query syntax is +Before composing modules, you'll need to define a query. The query syntax matches any number of `{erlang, terms}' and is composed as follows: * Simple Logic @@ -55,7 +55,7 @@ Select all events where 'a' exists. Select all events where 'a' does not exist. #+BEGIN_EXAMPLE - glc:nf(a, 0). + glc:nf(a). #+END_EXAMPLE Select no input events. User as a black hole query. @@ -72,22 +72,22 @@ Select all input events. Used as a passthrough query. * Combined Logic - Combined logic is defined as logic matching multiple event filters -Select all events where both 'a' `and' 'b' exists and are greater than 0. +Select all events where both 'a' AND 'b' exists and are greater than 0. #+BEGIN_EXAMPLE glc:all([glc:gt(a, 0), glc:gt(b, 0)]). #+END_EXAMPLE -Select all events where 'a' `or' 'b' exists and are greater than 0. +Select all events where 'a' OR 'b' exists and are greater than 0. #+BEGIN_EXAMPLE glc:any([glc:gt(a, 0), glc:gt(b, 0)]). #+END_EXAMPLE -Select all events where 'a' `and' 'b' exists where 'a' is greater than 1 and 'b' is less than 2. +Select all events where 'a' AND 'b' exists where 'a' is greater than 1 and 'b' is less than 2. #+BEGIN_EXAMPLE glc:all([glc:gt(a, 1), glc:lt(b, 2)]). #+END_EXAMPLE -Select all events where 'a' `or' 'b' exists where 'a' is greater than 1 and 'b' is less than 2. +Select all events where 'a' OR 'b' exists where 'a' is greater than 1 and 'b' is less than 2. #+BEGIN_EXAMPLE glc:any([glc:gt(a, 1), glc:lt(b, 2)]). #+END_EXAMPLE @@ -119,9 +119,7 @@ To compose a module you will take your Query defined above and compile it. #+END_EXAMPLE -# Handling Events # - -At this point you will be able to handle an event using a compiled query. +- At this point you will be able to handle an event using a compiled query. Begin by constructing an event list. #+BEGIN_EXAMPLE @@ -167,20 +165,24 @@ glc:filter(Module). #+END_EXAMPLE -## How to build ## +* Build - `$ ./rebar compile` +#+BEGIN_EXAMPLE + $ ./rebar compile +#+END_EXAMPLE or - `$ make` +#+BEGIN_EXAMPLE + $ make +#+END_EXAMPLE -## CHANGELOG ## +* CHANGELOG -### 0.1.6 ### +0.1.6 - Add notfound event matching -### 0.1.5 ### +0.1.5 - Rewrite to make highly crash resilient - per module supervision - statistics data recovery diff --git a/src/glc.erl b/src/glc.erl index bf82333..8b119bd 100644 --- a/src/glc.erl +++ b/src/glc.erl @@ -177,11 +177,11 @@ union(Queries) -> %% data associated with the query must be released using the {@link 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 --spec compile(atom(), list()) -> {ok, atom()}. +-spec compile(atom(), glc_ops:op() | [glc_ops:op()]) -> {ok, atom()}. compile(Module, Query) -> compile(Module, Query, true). --spec compile(atom(), list(), boolean()) -> {ok, atom()}. +-spec compile(atom(), glc_ops:op() | [glc_ops:op()], boolean()) -> {ok, atom()}. compile(Module, Query, Reset) -> {ok, ModuleData} = module_data(Module, Query), case glc_code:compile(Module, ModuleData) of @@ -228,9 +228,9 @@ delete(Module) -> ManageParams = manage_params_name(Module), ManageCounts = manage_counts_name(Module), - [ begin - supervisor:terminate_child(Sup, Name), - supervisor:delete_child(Sup, Name) + _ = [ begin + ok = supervisor:terminate_child(Sup, Name), + ok = supervisor:delete_child(Sup, Name) end || {Sup, Name} <- [{gr_manager_sup, ManageParams}, {gr_manager_sup, ManageCounts}, {gr_param_sup, Params}, {gr_counter_sup, Counts}] @@ -279,16 +279,16 @@ module_tables(Module) -> ManageCounts = manage_counts_name(Module), Counters = [{input,0}, {filter,0}, {output,0}], - supervisor:start_child(gr_param_sup, + _ = supervisor:start_child(gr_param_sup, {Params, {gr_param, start_link, [Params]}, transient, brutal_kill, worker, [Params]}), - supervisor:start_child(gr_counter_sup, + _ = supervisor:start_child(gr_counter_sup, {Counts, {gr_counter, start_link, [Counts]}, transient, brutal_kill, worker, [Counts]}), - supervisor:start_child(gr_manager_sup, + _ = supervisor:start_child(gr_manager_sup, {ManageParams, {gr_manager, start_link, [ManageParams, Params, []]}, transient, brutal_kill, worker, [ManageParams]}), - supervisor:start_child(gr_manager_sup, {ManageCounts, + _ = supervisor:start_child(gr_manager_sup, {ManageCounts, {gr_manager, start_link, [ManageCounts, Counts, Counters]}, transient, brutal_kill, worker, [ManageCounts]}), [{params,Params}, {counters, Counts}]. diff --git a/src/glc_lib.erl b/src/glc_lib.erl index b466f2b..18deaf7 100644 --- a/src/glc_lib.erl +++ b/src/glc_lib.erl @@ -265,7 +265,6 @@ is_valid(_Other) -> %% @private Assert that a term is a valid filter. %% If the term is a valid filter. The original term will be returned. %% If the term is not a valid filter. A `badarg' error is thrown. --spec valid(glc_ops:op()) -> boolean() | no_return(). valid(Term) -> is_valid(Term) orelse erlang:error(badarg, [Term]), Term. diff --git a/src/goldrush.app.src b/src/goldrush.app.src index afaefe6..2b607a3 100644 --- a/src/goldrush.app.src +++ b/src/goldrush.app.src @@ -1,6 +1,6 @@ {application, goldrush, [ {description, "Erlang event stream processor"}, - {vsn, "0.1.5"}, + {vsn, "0.1.6"}, {registered, []}, {applications, [kernel, stdlib, syntax_tools, compiler]}, {mod, {gr_app, []}}, diff --git a/src/gr_counter.erl b/src/gr_counter.erl index b8da06a..0824f82 100644 --- a/src/gr_counter.erl +++ b/src/gr_counter.erl @@ -160,7 +160,7 @@ handle_cast({update, Counter, Value}=Call, State) -> Waiting = State#state.waiting, State2 = case TableId of undefined -> State#state{waiting=[Call|Waiting]}; - _ -> handle_update_counter(TableId, Counter, Value), + _ -> _ = handle_update_counter(TableId, Counter, Value), State end, {noreply, State2}; @@ -178,9 +178,9 @@ handle_cast(_Msg, State) -> %% @end %%-------------------------------------------------------------------- handle_info({'ETS-TRANSFER', TableId, _Pid, _Data}, State) -> - [ gen_server:reply(From, perform_call(TableId, Call)) + _ = [ gen_server:reply(From, perform_call(TableId, Call)) || {Call, From} <- State#state.waiting ], - [ handle_update_counter(TableId, Counter, Value) + _ = [ handle_update_counter(TableId, Counter, Value) || {update, Counter, Value} <- State#state.waiting ], {noreply, State#state{table_id=TableId, waiting=[]}}; handle_info(_Info, State) -> diff --git a/src/gr_param.erl b/src/gr_param.erl index 125e7e3..96da689 100644 --- a/src/gr_param.erl +++ b/src/gr_param.erl @@ -188,7 +188,7 @@ handle_cast(_Msg, State) -> %% @end %%-------------------------------------------------------------------- handle_info({'ETS-TRANSFER', TableId, _Pid, _Data}, State) -> - [ gen_server:reply(From, perform_call(TableId, Call)) + _ = [ gen_server:reply(From, perform_call(TableId, Call)) || {Call, From} <- State#state.waiting ], {noreply, State#state{table_id=TableId, waiting=[]}}; handle_info(_Info, State) ->