Browse Source

Bump version to 0.1.6

develop-sidejob 0.1.6
Pedram Nimreezi 11 years ago
parent
commit
71e63212f1
6 changed files with 32 additions and 31 deletions
  1. +18
    -16
      README.org
  2. +9
    -9
      src/glc.erl
  3. +0
    -1
      src/glc_lib.erl
  4. +1
    -1
      src/goldrush.app.src
  5. +3
    -3
      src/gr_counter.erl
  6. +1
    -1
      src/gr_param.erl

+ 18
- 16
README.org View File

@ -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 with an erlang function. The function will be applied to each
output event from the query. output event from the query.
# Usage #
* Usage
To use goldrush in your application, you need to define it as a rebar dep or To use goldrush in your application, you need to define it as a rebar dep or
include it in erlang's path. 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: matches any number of `{erlang, terms}' and is composed as follows:
* Simple Logic * Simple Logic
@ -55,7 +55,7 @@ Select all events where 'a' exists.
Select all events where 'a' does not exist. Select all events where 'a' does not exist.
#+BEGIN_EXAMPLE #+BEGIN_EXAMPLE
glc:nf(a, 0).
glc:nf(a).
#+END_EXAMPLE #+END_EXAMPLE
Select no input events. User as a black hole query. 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
- Combined logic is defined as logic matching multiple event filters - 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 #+BEGIN_EXAMPLE
glc:all([glc:gt(a, 0), glc:gt(b, 0)]). glc:all([glc:gt(a, 0), glc:gt(b, 0)]).
#+END_EXAMPLE #+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 #+BEGIN_EXAMPLE
glc:any([glc:gt(a, 0), glc:gt(b, 0)]). glc:any([glc:gt(a, 0), glc:gt(b, 0)]).
#+END_EXAMPLE #+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 #+BEGIN_EXAMPLE
glc:all([glc:gt(a, 1), glc:lt(b, 2)]). glc:all([glc:gt(a, 1), glc:lt(b, 2)]).
#+END_EXAMPLE #+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 #+BEGIN_EXAMPLE
glc:any([glc:gt(a, 1), glc:lt(b, 2)]). glc:any([glc:gt(a, 1), glc:lt(b, 2)]).
#+END_EXAMPLE #+END_EXAMPLE
@ -119,9 +119,7 @@ To compose a module you will take your Query defined above and compile it.
#+END_EXAMPLE #+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 by constructing an event list.
#+BEGIN_EXAMPLE #+BEGIN_EXAMPLE
@ -167,20 +165,24 @@ glc:filter(Module).
#+END_EXAMPLE #+END_EXAMPLE
## How to build ##
* Build
`$ ./rebar compile`
#+BEGIN_EXAMPLE
$ ./rebar compile
#+END_EXAMPLE
or or
`$ make`
#+BEGIN_EXAMPLE
$ make
#+END_EXAMPLE
## CHANGELOG ##
* CHANGELOG
### 0.1.6 ###
0.1.6
- Add notfound event matching - Add notfound event matching
### 0.1.5 ###
0.1.5
- Rewrite to make highly crash resilient - Rewrite to make highly crash resilient
- per module supervision - per module supervision
- statistics data recovery - statistics data recovery

+ 9
- 9
src/glc.erl View File

@ -177,11 +177,11 @@ union(Queries) ->
%% data associated with the query must be released using the {@link delete/1} %% 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. %% function. The name of the query module is expected to be unique.
%% The counters are reset by default, unless Reset is set to false %% 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) ->
compile(Module, Query, true). 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) -> compile(Module, Query, Reset) ->
{ok, ModuleData} = module_data(Module, Query), {ok, ModuleData} = module_data(Module, Query),
case glc_code:compile(Module, ModuleData) of case glc_code:compile(Module, ModuleData) of
@ -228,9 +228,9 @@ delete(Module) ->
ManageParams = manage_params_name(Module), ManageParams = manage_params_name(Module),
ManageCounts = manage_counts_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} <- end || {Sup, Name} <-
[{gr_manager_sup, ManageParams}, {gr_manager_sup, ManageCounts}, [{gr_manager_sup, ManageParams}, {gr_manager_sup, ManageCounts},
{gr_param_sup, Params}, {gr_counter_sup, Counts}] {gr_param_sup, Params}, {gr_counter_sup, Counts}]
@ -279,16 +279,16 @@ module_tables(Module) ->
ManageCounts = manage_counts_name(Module), ManageCounts = manage_counts_name(Module),
Counters = [{input,0}, {filter,0}, {output,0}], 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]}, {Params, {gr_param, start_link, [Params]},
transient, brutal_kill, worker, [Params]}), transient, brutal_kill, worker, [Params]}),
supervisor:start_child(gr_counter_sup,
_ = supervisor:start_child(gr_counter_sup,
{Counts, {gr_counter, start_link, [Counts]}, {Counts, {gr_counter, start_link, [Counts]},
transient, brutal_kill, worker, [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, []]}, {ManageParams, {gr_manager, start_link, [ManageParams, Params, []]},
transient, brutal_kill, worker, [ManageParams]}), 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]}, {gr_manager, start_link, [ManageCounts, Counts, Counters]},
transient, brutal_kill, worker, [ManageCounts]}), transient, brutal_kill, worker, [ManageCounts]}),
[{params,Params}, {counters, Counts}]. [{params,Params}, {counters, Counts}].

+ 0
- 1
src/glc_lib.erl View File

@ -265,7 +265,6 @@ is_valid(_Other) ->
%% @private Assert that a term is a valid filter. %% @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 a valid filter. The original term will be returned.
%% If the term is not a valid filter. A `badarg' error is thrown. %% If the term is not a valid filter. A `badarg' error is thrown.
-spec valid(glc_ops:op()) -> boolean() | no_return().
valid(Term) -> valid(Term) ->
is_valid(Term) orelse erlang:error(badarg, [Term]), is_valid(Term) orelse erlang:error(badarg, [Term]),
Term. Term.

+ 1
- 1
src/goldrush.app.src View File

@ -1,6 +1,6 @@
{application, goldrush, [ {application, goldrush, [
{description, "Erlang event stream processor"}, {description, "Erlang event stream processor"},
{vsn, "0.1.5"},
{vsn, "0.1.6"},
{registered, []}, {registered, []},
{applications, [kernel, stdlib, syntax_tools, compiler]}, {applications, [kernel, stdlib, syntax_tools, compiler]},
{mod, {gr_app, []}}, {mod, {gr_app, []}},

+ 3
- 3
src/gr_counter.erl View File

@ -160,7 +160,7 @@ handle_cast({update, Counter, Value}=Call, State) ->
Waiting = State#state.waiting, Waiting = State#state.waiting,
State2 = case TableId of State2 = case TableId of
undefined -> State#state{waiting=[Call|Waiting]}; undefined -> State#state{waiting=[Call|Waiting]};
_ -> handle_update_counter(TableId, Counter, Value),
_ -> _ = handle_update_counter(TableId, Counter, Value),
State State
end, end,
{noreply, State2}; {noreply, State2};
@ -178,9 +178,9 @@ handle_cast(_Msg, State) ->
%% @end %% @end
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
handle_info({'ETS-TRANSFER', TableId, _Pid, _Data}, State) -> 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 ], || {Call, From} <- State#state.waiting ],
[ handle_update_counter(TableId, Counter, Value)
_ = [ handle_update_counter(TableId, Counter, Value)
|| {update, Counter, Value} <- State#state.waiting ], || {update, Counter, Value} <- State#state.waiting ],
{noreply, State#state{table_id=TableId, waiting=[]}}; {noreply, State#state{table_id=TableId, waiting=[]}};
handle_info(_Info, State) -> handle_info(_Info, State) ->

+ 1
- 1
src/gr_param.erl View File

@ -188,7 +188,7 @@ handle_cast(_Msg, State) ->
%% @end %% @end
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
handle_info({'ETS-TRANSFER', TableId, _Pid, _Data}, State) -> 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 ], || {Call, From} <- State#state.waiting ],
{noreply, State#state{table_id=TableId, waiting=[]}}; {noreply, State#state{table_id=TableId, waiting=[]}};
handle_info(_Info, State) -> handle_info(_Info, State) ->

Loading…
Cancel
Save