Skip to content

Commit

Permalink
Merge pull request #22 from bosqueviejo/master
Browse files Browse the repository at this point in the history
0.12.0 - Multiconnections
  • Loading branch information
artefactop committed Jul 8, 2013
2 parents 2fc4ba8 + c111625 commit eb42b39
Show file tree
Hide file tree
Showing 15 changed files with 918 additions and 326 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ script : "./rebar compile && ./rebar skip_deps=true eunit"
otp_release:
- R16B
- R15B02
- R15B01
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ The example file `app.config` have the following sections:
{ecomponent, [
{syslog_name, "{{component_name}}" },
{jid, "{{component_name}}.{{xmpp_domain}}" },
{server, "{{xmpp_server_host}}" },
{port, {{xmpp_server_port}} },
{pass, "{{xmpp_server_pass}}" },
{servers, [
{server_one, [
{server, "{{xmpp_server_host}}" },
{port, {{xmpp_server_port}} },
{pass, "{{xmpp_server_pass}}" }
]}
]},
{whitelist, [domain::Binary] }, %% throttle whitelist
{access_list_get, [{namespace::Atom, [domain::Binary]}]},
{access_list_set, [{namespace::Atom, [domain::Binary]}]},
Expand Down
50 changes: 50 additions & 0 deletions include/ecomponent_internal.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
-include_lib("exmpp/include/exmpp_jid.hrl").
-include_lib("exmpp/include/exmpp.hrl").
-include_lib("exmpp/include/exmpp_client.hrl").
-include_lib("confetti/include/confetti.hrl").
-include("../include/ecomponent.hrl").

-type jid() :: { Name::string(), Server::string(), Resource::string() }.

-type mod_processor() :: {mod, Module::atom()}.

-type app_processor() :: {app, App::atom()}.

-type message_processor() :: mod_processor() | app_processor().

-type presence_processor() :: mod_processor() | app_processor().

-type processor() :: {Name::atom(), Value::(mod_processor() | app_processor())}.

-type accesslist() :: Domains::list(binary()).

-export_type([jid/0]).

-define(MAX_PER_PERIOD, 10).
-define(PERIOD_SECONDS, 6).
-define(MAX_TRIES, 3).
-define(RESEND_PERIOD, 100).
-define(REQUEST_TIMEOUT, 10).
-define(SYSLOG_FACILITY, local7).
-define(SYSLOG_NAME, "ecomponent").

-record(state, {
jid :: jid(),
whiteList = [] :: list(string()),
maxPerPeriod = ?MAX_PER_PERIOD :: integer(),
periodSeconds = ?PERIOD_SECONDS :: integer(),
processors :: list(processor()),
message_processor :: message_processor(),
presence_processor :: presence_processor(),
maxTries = ?MAX_TRIES :: integer(),
resendPeriod = ?RESEND_PERIOD :: integer(),
requestTimeout = ?REQUEST_TIMEOUT :: integer(),
accessListSet = [] :: accesslist(),
accessListGet = [] :: accesslist(),
syslogFacility = ?SYSLOG_FACILITY :: atom(),
syslogName = ?SYSLOG_NAME :: string(),
timeout = undefined :: integer(),
features = [] :: [binary()],
info = [] :: proplists:proplists(),
disco_info = true :: boolean()
}).
13 changes: 7 additions & 6 deletions include/ecomponent_test.hrl
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
% snippets for tests

% required for eunit to work
-include_lib("exmpp/include/exmpp_jid.hrl").
-include_lib("exmpp/include/exmpp.hrl").
-include_lib("exmpp/include/exmpp_client.hrl").
-include_lib("eunit/include/eunit.hrl").
-include("../include/ecomponent.hrl").
-include("../include/ecomponent_internal.hrl").

-define(run_exmpp(), begin
case lists:keyfind(exmpp, 1, application:loaded_applications()) of
Expand Down Expand Up @@ -44,7 +41,7 @@ end).

-define(meck_confetti(Config), begin
meck:new(confetti),
meck:expect(confetti, fetch, fun(mgmt_conf) -> Config end)
meck:expect(confetti, fetch, 1, Config)
end).

-define(meck_component(), begin
Expand Down Expand Up @@ -119,7 +116,11 @@ end).
end).

-define(no_try_catch(NoMatch, Timeout),
(fun() -> receive NoMatch -> throw("Matching!"); _ -> ok after Timeout -> ok end end)()
(fun() -> receive NoMatch=NM -> ?debugFmt("match: ~p~n", [NM]), throw("Matching!"); _ -> ok after Timeout -> ok end end)()
).

-define(try_catch_match(Match, Timeout),
(fun() -> receive Match; Any -> throw(Any) after Timeout -> throw("TIMEOUT") end end)()
).

-define(try_catch(Match, Timeout),
Expand Down
2 changes: 2 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
{meck, ".*", {git, "git://github.com/eproxus/meck.git", "0.7.2"}},
{uuid, ".*", {git, "git://github.com/avtobiff/erlang-uuid.git", "v0.3.3"}},
{folsom_cowboy, ".*", {git, "git://github.com/bosqueviejo/folsom_cowboy.git", "0.1.1"}},

% only for test, don't include them in reltool
{ct_tools, ".*", {git, "git://github.com/garazdawi/cth_tools.git", "658166d70b9c0f7d2e16dba44c1e0de93300f08e"}},
{covertool,".*", {git, "https://github.com/idubrov/covertool.git", "e1179ca7c7e6493fa5bcfb4158b72a9582aff562"}}
]}.
Expand Down
Loading

0 comments on commit eb42b39

Please sign in to comment.