aboutsummaryrefslogtreecommitdiff
path: root/src/mod_pres_counter.erl
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2018-01-23 10:54:52 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2018-01-23 10:54:52 +0300
commitba2b650464bd3aae2b6b0f3a3177476360cb6d08 (patch)
tree5d55501f76edcdcfe145ba0c3367a54ea0314e5c /src/mod_pres_counter.erl
parentDo not try to start ezlib application too frequently (diff)
Introduce new gen_mod callback: mod_options/1
The callback is supposed to provide known options and their default values, as long as the documentation. Passing default values into get_mod functions is now deprecated: all defaults should be provided by the Mod:mod_options/1 callback.
Diffstat (limited to '')
-rw-r--r--src/mod_pres_counter.erl12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mod_pres_counter.erl b/src/mod_pres_counter.erl
index c747eb361..62e4fc08f 100644
--- a/src/mod_pres_counter.erl
+++ b/src/mod_pres_counter.erl
@@ -28,7 +28,7 @@
-behavior(gen_mod).
-export([start/2, stop/1, reload/3, check_packet/4,
- mod_opt_type/1, depends/2]).
+ mod_opt_type/1, mod_options/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
@@ -79,8 +79,8 @@ check_packet(Acc, _, _, _) ->
Acc.
update(Server, JID, Dir) ->
- StormCount = gen_mod:get_module_opt(Server, ?MODULE, count, 5),
- TimeInterval = gen_mod:get_module_opt(Server, ?MODULE, interval, 60),
+ StormCount = gen_mod:get_module_opt(Server, ?MODULE, count),
+ TimeInterval = gen_mod:get_module_opt(Server, ?MODULE, interval),
TimeStamp = p1_time_compat:system_time(seconds),
case read(Dir) of
undefined ->
@@ -126,5 +126,7 @@ write(K, V) -> put({pres_counter, K}, V).
mod_opt_type(count) ->
fun (I) when is_integer(I), I > 0 -> I end;
mod_opt_type(interval) ->
- fun (I) when is_integer(I), I > 0 -> I end;
-mod_opt_type(_) -> [count, interval].
+ fun (I) when is_integer(I), I > 0 -> I end.
+
+mod_options(_) ->
+ [{count, 5}, {interval, 60}].