Skip to content

Commit

Permalink
#11 - use gen_fsm or gen_statem and removes neotoma because it's incl…
Browse files Browse the repository at this point in the history
…uded by sqlparser
  • Loading branch information
Manuel Rubio committed Feb 9, 2018
1 parent d115205 commit eeaeea6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{erl_opts, [
debug_info,
warnings_as_errors
warnings_as_errors,
{platform_define, "17|18", 'OLD_GEN_FSM'}
]}.

{deps, [
neotoma,
{sqlparser, "0.2.0"}
]}.

Expand Down
10 changes: 8 additions & 2 deletions src/my_request.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
-module(my_request).
-author('Manuel Rubio <[email protected]>').

-behaviour(gen_fsm).
-ifdef(OLD_GEN_FSM).
-define(GEN_FSM, gen_fsm).
-else.
-define(GEN_FSM, gen_statem).
-endif.

-behaviour(?GEN_FSM).

-define(SERVER, ?MODULE).

Expand Down Expand Up @@ -46,7 +52,7 @@
ParseQuery :: boolean()) -> {ok, pid()}.

start(Socket, Id, Handler, ParseQuery) ->
{ok, Pid} = gen_fsm:start(?MODULE, [Socket, Id, Handler, ParseQuery], []),
{ok, Pid} = ?GEN_FSM:start(?MODULE, [Socket, Id, Handler, ParseQuery], []),
gen_tcp:controlling_process(Socket, Pid),
inet:setopts(Socket, [{active, true}]),
{ok, Pid}.
Expand Down

0 comments on commit eeaeea6

Please sign in to comment.