Permalink
Browse files

Giving the project the Brujo's touch :P

Project modules were restructured according to Inaka's "Best Practices".
Now it's PING-PONG'ing, too.
  • Loading branch information...
1 parent 4dbd3a8 commit 78f94515fb8cb1f9af6305444df2649d74da3918 Fernando 'Brujo' Benavides committed Sep 28, 2011
View
@@ -1,3 +1,4 @@
+deps
log/*.log
tmp
tmp/**/*
View
@@ -0,0 +1,2 @@
+{"src/*", [warn_unused_vars, warn_export_all, warn_shadow_vars, warn_unused_import, warn_unused_function, warn_bif_clash, warn_unused_record, warn_deprecated_function, warn_obsolete_guard, strict_validation, report, warn_export_vars, warn_exported_vars, warn_missing_spec, warn_untyped_record, debug_info, {outdir, "ebin"}, {i, "include"}, {i, "deps/elog/include"}]}.
+{"tests/*", [warn_unused_vars, warn_export_all, warn_shadow_vars, warn_unused_import, warn_unused_function, warn_bif_clash, warn_unused_record, warn_deprecated_function, warn_obsolete_guard, strict_validation, report, warn_export_vars, warn_exported_vars, warn_missing_spec, warn_untyped_record, debug_info, {outdir, "ebin"}, {i, "include"}, {i, "deps/elog/include"}]}.
View
@@ -0,0 +1,28 @@
+ERL := erl -pa deps/*/ebin -pa ebin -pa src -s crypto -boot start_sasl +Bc +K true -smp enable -s inets -s ssl -s elog ${ERL_ARGS}
+
+all:
+ rebar get-deps && rebar compile
+
+clean:
+ rebar clean
+
+build_plt: all
+ dialyzer --build_plt --apps ssl public_key kernel stdlib inets crypto --output_plt ~/.edis_plt -pa deps/*/ebin ebin
+
+analyze: all
+ dialyzer -pa deps/*/ebin --plt ~/.itweet_dialyzer_plt -Wunmatched_returns -Werror_handling -Wbehaviours ebin
+
+doc: all
+ rebar skip_deps=true doc
+
+xref: all
+ rebar skip_deps=true xref
+
+run: all
+ ${ERL} -s edis
+
+test: all
+ ${ERL} -run edis test
+
+shell: all
+ ${ERL}
View
@@ -0,0 +1 @@
+An *Erlang* version of [Redis](http://redis.io). Still in its very early stages.
View
@@ -1,18 +0,0 @@
-task :default => [:make_erl]
-
-task :clean do
- print "Cleaning..."
- sh "rebar clean"
- print " done\n"
-end
-
-task :make_erl do
- print "Compiling Erlang sources..."
- sh "rebar compile"
- print " done\n"
-end
-
-task :run do
- sh "erl -pa ebin -pa src -s crypto -boot start_sasl +Bc +K true -smp enable -run edis_app boot"
-end
-
View
@@ -1,9 +1,11 @@
{application,edis,
- [{description,[]},
- {vsn,"1"},
+ [{description,"Redis KV Store - The Erlang Way :)"},
+ {vsn,"0.1"},
{registered,[]},
- {applications,[kernel,stdlib]},
- {mod,{edis_app,[]}},
- {env,[]},
- {modules,[client_handler,client_manager,config,edis_app,
- edis_sup,server,tcp_listener]}]}.
+ {applications,[kernel,stdlib,crypto]},
+ {mod,{edis,[]}},
+ {env,[{listener_port_range,{6379,6379}},{client_timeout,32000}]},
+ {modules,[client_handler,client_manager,config,edis,edis_app,
+ edis_client,edis_client_mgr,edis_client_sup,
+ edis_config,edis_listener,edis_listener_sup,edis_sup,
+ server,tcp_listener]}]}.
View
@@ -0,0 +1,2 @@
+-include("elog.hrl").
+
View
@@ -1,63 +0,0 @@
-%%%-------------------------------------------------------------------
-%%% @doc Macros used to selectively send debugging information
-%%%-------------------------------------------------------------------
-
-%%NOTE: We do this because we want to step over other definitions of these macros
--undef(LOG_LEVEL_DEBUG).
--undef(LOG_LEVEL_INFO).
--undef(LOG_LEVEL_STAT).
--undef(LOG_LEVEL_WARN).
--undef(LOG_LEVEL_ERROR).
--undef(LOG_LEVEL_FATAL).
--undef(LOG_LEVELS).
--undef(LOG).
--undef(DEBUG).
--undef(INFO).
--undef(WARN).
--undef(STAT).
--undef(ERROR).
--undef(FATAL).
-
--define(LOG_LEVEL_DEBUG, debug).
--define(LOG_LEVEL_INFO, info).
--define(LOG_LEVEL_STAT, stat).
--define(LOG_LEVEL_WARN, warn).
--define(LOG_LEVEL_ERROR, error).
--define(LOG_LEVEL_FATAL, fatal).
--define(LOG_LEVELS, [?LOG_LEVEL_DEBUG, ?LOG_LEVEL_INFO, ?LOG_LEVEL_STAT,
- ?LOG_LEVEL_WARN, ?LOG_LEVEL_ERROR, ?LOG_LEVEL_FATAL]).
--type loglevel() :: ?LOG_LEVEL_DEBUG | ?LOG_LEVEL_INFO | ?LOG_LEVEL_STAT | ?LOG_LEVEL_WARN | ?LOG_LEVEL_ERROR | ?LOG_LEVEL_FATAL.
-
--record(log, {time = erlang:localtime() :: {{integer(),integer(),integer()},{integer(),integer(),integer()}},
- level :: loglevel(),
- module :: atom(),
- line :: integer(),
- pid :: pid(),
- node :: node(),
- stacktrace = [] :: [term()],
- text = "" :: string(),
- args = [] :: [term()]}).
-
--define(LOG(LOGProcess, LOGLevel, LOGStr, LOGArgs, LOGStack),
- try
- gen_server:cast(LOGProcess,
- #log{module = ?MODULE,
- level = LOGLevel,
- line = ?LINE,
- pid = self(),
- node = node(),
- stacktrace = LOGStack,
- text = LOGStr,
- args = LOGArgs})
- catch
- _ ->
- error_logger:error_msg("Exception trying to log a message:~p~n",
- [{LOGStr, LOGArgs}])
- end).
--define(DEBUG(Str, Args), io:format(Str,Args)).
--define(INFO(Str, Args), ok = hd([ok, Str | Args])).
--define(STAT(Str, Args), ?LOG('edis-stat', ?LOG_LEVEL_STAT, Str, Args, [])).
--define(WARN(Str, Args), ?LOG('edis-warn', ?LOG_LEVEL_WARN, Str, Args, [])).
--define(ERROR(Str, Args), ?LOG('edis-error', ?LOG_LEVEL_ERROR, Str, Args, erlang:get_stacktrace())).
--define(THROW(Str, Args), try throw({}) catch _:_ -> ?LOG('edis-error', ?LOG_LEVEL_ERROR, Str, Args, erlang:get_stacktrace()) end).
--define(FATAL(Str, Args), ?LOG('edis-fatal', ?LOG_LEVEL_FATAL, Str, Args, erlang:get_stacktrace())).
View
@@ -0,0 +1,19 @@
+{deps, [{elog, "\.*", {git, "git://github.com/inaka/elog.git", "master"}}]}.
+{require_otp_vsn, "R14"}.
+{erl_opts, [{src_dirs, ["src", "tests"]},
+ {i, "deps/elog/include"},
+ warn_unused_vars,
+ warn_export_all,
+ warn_shadow_vars,
+ warn_unused_import,
+ warn_unused_function,
+ warn_bif_clash,
+ warn_unused_record,
+ warn_deprecated_function,
+ warn_obsolete_guard,
+ strict_validation,
+ warn_export_vars,
+ warn_exported_vars,
+ warn_missing_spec,
+ warn_untyped_record, debug_info]}.
+{xref_checks, [undefined_function_calls]}.
@@ -1,50 +0,0 @@
-%%%-------------------------------------------------------------------
-%%% @author Fernando Benavides <fernando.benavides@inakanetworks.com>
-%%% @copyright (C) 2010 InakaLabs S.R.L.
-%%% @doc Supervisor for Client Processes
-%%% @end
-%%%-------------------------------------------------------------------
--module(client_manager).
-
--behaviour(supervisor).
-
--export([start_link/0, start_client/0, init/1]).
-
--include("log.hrl").
-
-%% ====================================================================
-%% External functions
-%% ====================================================================
-%% @spec start_link() -> ignore | {error, term()} | {ok, pid()}
-%% @doc Starts the supervisor process
--spec start_link() -> ignore | {error, term()} | {ok, pid()}.
-start_link() ->
- supervisor:start_link({local, ?MODULE}, ?MODULE, []).
-
-%% @spec start_client() -> {ok, pid() | undefined} | {error, term()}
-%% @doc Starts a new client process
--spec start_client() -> {ok, pid() | undefined} | {error, term()}.
-start_client() ->
- supervisor:start_child(?MODULE, []).
-
-%% ====================================================================
-%% Server functions
-%% ====================================================================
-%% @hidden
--spec init([]) -> {ok, {{simple_one_for_one, 100, 1}, [supervisor:child_spec()]}}.
-init([]) ->
- {ok,
- {_SupFlags = {simple_one_for_one, 100, 1},
- [
- % TCP Client
- { undefined, % Id = internal id
- {client_handler, start_link, []}, % StartFun = {M, F, A}
- temporary, % Restart = permanent | transient | temporary
- brutal_kill, % Shutdown = brutal_kill | int() >= 0 | infinity
- worker, % Type = worker | supervisor
- [client_handler] % Modules = [Module] | dynamic
- }
- ]
- }
- }.
-
View
@@ -1,16 +0,0 @@
--module(config).
--compile([export_all]).
-
--include("log.hrl").
-
-get_env(Field, Default) ->
- case application:get_env(italk, Field) of
- {ok, Value} ->
- ?DEBUG("~p := ~p~n", [Field, Value]),
- Value;
- _ ->
- ?DEBUG("~p := ~p~n", [Field, Default]),
- Default
- end.
-
-
View
@@ -1,12 +1,14 @@
{application, edis,
[
- {description, ""},
- {vsn, "1"},
+ {description, "Redis KV Store - The Erlang Way :)"},
+ {vsn, "0.1"},
{registered, []},
{applications, [
kernel,
- stdlib
+ stdlib,
+ crypto
]},
- {mod, { edis_app, []}},
- {env, []}
+ {mod, {edis, []}},
+ {env, [{listener_port_range, {6379,6379}},
+ {client_timeout, 32000}]}
]}.
View
@@ -0,0 +1,40 @@
+%%%-------------------------------------------------------------------
+%%% @author Fernando Benavides <fernando.benavides@inakanetworks.com>
+%%% @author Chad DePue <chad@inakanetworks.com>
+%%% @copyright (C) 2011 InakaLabs SRL
+%%% @doc Redis (http://redis.io), but in Erlang
+%%% @end
+%%%-------------------------------------------------------------------
+-module(edis).
+-author('Fernando Benavides <fernando.benavides@inakanetworks.com>').
+-author('Chad DePue <chad@inakanetworks.com>').
+-vsn('0.1').
+
+-behaviour(application).
+
+%% Application callbacks
+-export([start/0, stop/0]).
+-export([start/2, stop/1]).
+
+%%-------------------------------------------------------------------
+%% ADMIN API
+%%-------------------------------------------------------------------
+%% @doc Starts the application
+-spec start() -> ok | {error, {already_started, ?MODULE}}.
+start() -> application:start(?MODULE).
+
+%% @doc Stops the application
+-spec stop() -> ok.
+stop() -> application:stop(?MODULE).
+
+%%-------------------------------------------------------------------
+%% BEHAVIOUR CALLBACKS
+%%-------------------------------------------------------------------
+%% @private
+-spec start(any(), any()) -> {ok, pid()}.
+start(_StartType, _StartArgs) ->
+ edis_sup:start_link().
+
+%% @private
+-spec stop(any()) -> ok.
+stop(_State) -> ok.
View
@@ -1,19 +0,0 @@
--module(edis_app).
-
--behaviour(application).
-
-%% Application callbacks
--export([start/2, stop/1, boot/0]).
-
-%% ===================================================================
-%% Application callbacks
-%% ===================================================================
-
-boot() ->
- application:start(edis).
-
-start(_StartType, _StartArgs) ->
- edis_sup:start_link().
-
-stop(_State) ->
- ok.
Oops, something went wrong. Retry.

0 comments on commit 78f9451

Please sign in to comment.