mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Get rid of "well-known" type
This commit is contained in:
parent
67fbbe7a0b
commit
a205ebad2b
@ -49,7 +49,8 @@
|
||||
-export([acl/0, shaper/0, url_or_file/0, lang/0]).
|
||||
-export([pem/0, queue_type/0]).
|
||||
-export([jid/0, user/0, domain/0, resource/0]).
|
||||
-export([db_type/1, ldap_filter/0, well_known/2]).
|
||||
-export([db_type/1, ldap_filter/0]).
|
||||
-export([host/0, hosts/0]).
|
||||
-ifdef(SIP).
|
||||
-export([sip_uri/0]).
|
||||
-endif.
|
||||
@ -462,25 +463,6 @@ ldap_filter() ->
|
||||
end
|
||||
end).
|
||||
|
||||
well_known(queue_type, _) ->
|
||||
queue_type();
|
||||
well_known(db_type, M) ->
|
||||
db_type(M);
|
||||
well_known(ram_db_type, M) ->
|
||||
db_type(M);
|
||||
well_known(cache_life_time, _) ->
|
||||
pos_int(infinity);
|
||||
well_known(cache_size, _) ->
|
||||
pos_int(infinity);
|
||||
well_known(use_cache, _) ->
|
||||
bool();
|
||||
well_known(cache_missed, _) ->
|
||||
bool();
|
||||
well_known(host, _) ->
|
||||
host();
|
||||
well_known(hosts, _) ->
|
||||
list(host(), [unique]).
|
||||
|
||||
-ifdef(SIP).
|
||||
sip_uri() ->
|
||||
and_then(
|
||||
@ -507,6 +489,10 @@ host() ->
|
||||
end
|
||||
end.
|
||||
|
||||
-spec hosts() -> yconf:validator([binary()]).
|
||||
hosts() ->
|
||||
list(host(), [unique]).
|
||||
|
||||
%%%===================================================================
|
||||
%%% Internal functions
|
||||
%%%===================================================================
|
||||
|
@ -768,10 +768,7 @@ init_cache(HostModules) ->
|
||||
cache_opts() ->
|
||||
MaxSize = ejabberd_option:auth_cache_size(),
|
||||
CacheMissed = ejabberd_option:auth_cache_missed(),
|
||||
LifeTime = case ejabberd_option:auth_cache_life_time() of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = ejabberd_option:auth_cache_life_time(),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
-spec use_cache(map()) -> {True :: [module()], False :: [module()]}.
|
||||
|
@ -366,10 +366,7 @@ use_cache(DBMod) ->
|
||||
cache_opts() ->
|
||||
MaxSize = ejabberd_option:oauth_cache_size(),
|
||||
CacheMissed = ejabberd_option:oauth_cache_missed(),
|
||||
LifeTime = case ejabberd_option:oauth_cache_life_time() of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = ejabberd_option:oauth_cache_life_time(),
|
||||
[{max_size, MaxSize}, {life_time, LifeTime}, {cache_missed, CacheMissed}].
|
||||
|
||||
expire() ->
|
||||
|
@ -57,7 +57,7 @@ opt_type(append_host_config) ->
|
||||
econf:enum(ejabberd_option:hosts())),
|
||||
validator());
|
||||
opt_type(auth_cache_life_time) ->
|
||||
econf:pos_int(infinity);
|
||||
econf:timeout(second, infinity);
|
||||
opt_type(auth_cache_missed) ->
|
||||
econf:bool();
|
||||
opt_type(auth_cache_size) ->
|
||||
@ -83,7 +83,7 @@ opt_type(c2s_tls_compression) ->
|
||||
opt_type(ca_file) ->
|
||||
econf:pem();
|
||||
opt_type(cache_life_time) ->
|
||||
econf:pos_int(infinity);
|
||||
econf:timeout(second, infinity);
|
||||
opt_type(cache_missed) ->
|
||||
econf:bool();
|
||||
opt_type(cache_size) ->
|
||||
@ -219,7 +219,7 @@ opt_type(new_sql_schema) ->
|
||||
opt_type(oauth_access) ->
|
||||
econf:acl();
|
||||
opt_type(oauth_cache_life_time) ->
|
||||
econf:pos_int(infinity);
|
||||
econf:timeout(second, infinity);
|
||||
opt_type(oauth_cache_missed) ->
|
||||
econf:bool();
|
||||
opt_type(oauth_cache_size) ->
|
||||
@ -295,7 +295,7 @@ opt_type(riak_username) ->
|
||||
opt_type(route_subdomains) ->
|
||||
econf:enum([s2s, local]);
|
||||
opt_type(router_cache_life_time) ->
|
||||
econf:pos_int(infinity);
|
||||
econf:timeout(second, infinity);
|
||||
opt_type(router_cache_missed) ->
|
||||
econf:bool();
|
||||
opt_type(router_cache_size) ->
|
||||
@ -347,7 +347,7 @@ opt_type(shaper) ->
|
||||
opt_type(shaper_rules) ->
|
||||
ejabberd_shaper:validator(shaper_rules);
|
||||
opt_type(sm_cache_life_time) ->
|
||||
econf:pos_int(infinity);
|
||||
econf:timeout(second, infinity);
|
||||
opt_type(sm_cache_missed) ->
|
||||
econf:bool();
|
||||
opt_type(sm_cache_size) ->
|
||||
@ -435,7 +435,7 @@ options() ->
|
||||
[%% Top-priority options
|
||||
hosts,
|
||||
{loglevel, 4},
|
||||
{cache_life_time, 3600},
|
||||
{cache_life_time, timer:seconds(3600)},
|
||||
{cache_missed, true},
|
||||
{cache_size, 1000},
|
||||
{use_cache, true},
|
||||
|
@ -468,10 +468,7 @@ init_cache(Mod) ->
|
||||
cache_opts() ->
|
||||
MaxSize = ejabberd_option:router_cache_size(),
|
||||
CacheMissed = ejabberd_option:router_cache_missed(),
|
||||
LifeTime = case ejabberd_option:router_cache_life_time() of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = ejabberd_option:router_cache_life_time(),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
-spec clean_cache(node()) -> non_neg_integer().
|
||||
|
@ -912,10 +912,7 @@ init_cache() ->
|
||||
cache_opts() ->
|
||||
MaxSize = ejabberd_option:sm_cache_size(),
|
||||
CacheMissed = ejabberd_option:sm_cache_missed(),
|
||||
LifeTime = case ejabberd_option:sm_cache_life_time() of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = ejabberd_option:sm_cache_life_time(),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
-spec clean_cache(node()) -> non_neg_integer().
|
||||
|
@ -855,10 +855,7 @@ init_cache(Mod, Host, Opts) ->
|
||||
cache_opts(Opts) ->
|
||||
MaxSize = mod_announce_opt:cache_size(Opts),
|
||||
CacheMissed = mod_announce_opt:cache_missed(Opts),
|
||||
LifeTime = case mod_announce_opt:cache_life_time(Opts) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_announce_opt:cache_life_time(Opts),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
-spec use_cache(module(), binary()) -> boolean().
|
||||
@ -900,15 +897,15 @@ import(LServer, {sql, _}, DBType, Tab, List) ->
|
||||
mod_opt_type(access) ->
|
||||
econf:acl();
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(use_cache) ->
|
||||
econf:well_known(use_cache, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_missed) ->
|
||||
econf:well_known(cache_missed, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
mod_options(Host) ->
|
||||
[{access, none},
|
||||
|
@ -170,17 +170,17 @@ mod_opt_type(max_pause) ->
|
||||
mod_opt_type(prebind) ->
|
||||
econf:bool();
|
||||
mod_opt_type(queue_type) ->
|
||||
econf:well_known(queue_type, ?MODULE);
|
||||
econf:queue_type();
|
||||
mod_opt_type(ram_db_type) ->
|
||||
econf:well_known(ram_db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(use_cache) ->
|
||||
econf:well_known(use_cache, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_missed) ->
|
||||
econf:well_known(cache_missed, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
-spec mod_options(binary()) -> [{json, boolean()} |
|
||||
{atom(), term()}].
|
||||
@ -240,10 +240,7 @@ delete_cache(Mod, SID) ->
|
||||
cache_opts(Host) ->
|
||||
MaxSize = mod_bosh_opt:cache_size(Host),
|
||||
CacheMissed = mod_bosh_opt:cache_missed(Host),
|
||||
LifeTime = case mod_bosh_opt:cache_life_time(Host) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_bosh_opt:cache_life_time(Host),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
-spec clean_cache(node()) -> non_neg_integer().
|
||||
|
@ -503,10 +503,7 @@ use_cache(Mod, Host) ->
|
||||
cache_opts(Opts) ->
|
||||
MaxSize = mod_caps_opt:cache_size(Opts),
|
||||
CacheMissed = mod_caps_opt:cache_missed(Opts),
|
||||
LifeTime = case mod_caps_opt:cache_life_time(Opts) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_caps_opt:cache_life_time(Opts),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
export(LServer) ->
|
||||
@ -545,15 +542,15 @@ import_next(LServer, DBType, NodePair) ->
|
||||
import_next(LServer, DBType, ets:next(caps_features_tmp, NodePair)).
|
||||
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(use_cache) ->
|
||||
econf:well_known(use_cache, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_missed) ->
|
||||
econf:well_known(cache_missed, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
mod_options(Host) ->
|
||||
[{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||
|
@ -193,9 +193,9 @@ mod_opt_type(thumbnail) ->
|
||||
mod_opt_type(external_secret) ->
|
||||
econf:binary();
|
||||
mod_opt_type(host) ->
|
||||
econf:well_known(host, ?MODULE);
|
||||
econf:host();
|
||||
mod_opt_type(hosts) ->
|
||||
econf:well_known(hosts, ?MODULE).
|
||||
econf:hosts().
|
||||
|
||||
-spec mod_options(binary()) -> [{thumbnail, boolean()} |
|
||||
{atom(), any()}].
|
||||
|
@ -270,10 +270,7 @@ init_cache(Mod, Host, Opts) ->
|
||||
cache_opts(Opts) ->
|
||||
MaxSize = mod_last_opt:cache_size(Opts),
|
||||
CacheMissed = mod_last_opt:cache_missed(Opts),
|
||||
LifeTime = case mod_last_opt:cache_life_time(Opts) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_last_opt:cache_life_time(Opts),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
-spec use_cache(module(), binary()) -> boolean().
|
||||
@ -316,15 +313,15 @@ depends(_Host, _Opts) ->
|
||||
[].
|
||||
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(use_cache) ->
|
||||
econf:well_known(use_cache, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_missed) ->
|
||||
econf:well_known(cache_missed, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
mod_options(Host) ->
|
||||
[{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||
|
@ -176,10 +176,7 @@ init_cache(Mod, Host, Opts) ->
|
||||
cache_opts(Opts) ->
|
||||
MaxSize = mod_mam_opt:cache_size(Opts),
|
||||
CacheMissed = mod_mam_opt:cache_missed(Opts),
|
||||
LifeTime = case mod_mam_opt:cache_life_time(Opts) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_mam_opt:cache_life_time(Opts),
|
||||
[{max_size, MaxSize}, {life_time, LifeTime}, {cache_missed, CacheMissed}].
|
||||
|
||||
stop(Host) ->
|
||||
@ -1404,15 +1401,15 @@ mod_opt_type(user_mucsub_from_muc_archive) ->
|
||||
mod_opt_type(access_preferences) ->
|
||||
econf:acl();
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(use_cache) ->
|
||||
econf:well_known(use_cache, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_missed) ->
|
||||
econf:well_known(cache_missed, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
mod_options(Host) ->
|
||||
[{assume_mam_usage, false},
|
||||
|
@ -82,11 +82,11 @@ mod_opt_type(access_create) ->
|
||||
mod_opt_type(name) ->
|
||||
econf:binary();
|
||||
mod_opt_type(host) ->
|
||||
econf:well_known(host, ?MODULE);
|
||||
econf:host();
|
||||
mod_opt_type(hosts) ->
|
||||
econf:well_known(hosts, ?MODULE);
|
||||
econf:hosts();
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE).
|
||||
econf:db_type(?MODULE).
|
||||
|
||||
mod_options(Host) ->
|
||||
[{access_create, all},
|
||||
|
@ -85,15 +85,15 @@ depends(_Host, _Opts) ->
|
||||
[].
|
||||
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(use_cache) ->
|
||||
econf:well_known(use_cache, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_missed) ->
|
||||
econf:well_known(cache_missed, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
mod_options(Host) ->
|
||||
[{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||
@ -334,10 +334,7 @@ init_cache(Mod, Host, Opts) ->
|
||||
cache_opts(Opts) ->
|
||||
MaxSize = mod_mix_pam_opt:cache_size(Opts),
|
||||
CacheMissed = mod_mix_pam_opt:cache_missed(Opts),
|
||||
LifeTime = case mod_mix_pam_opt:cache_life_time(Opts) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_mix_pam_opt:cache_life_time(Opts),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
-spec use_cache(module(), binary()) -> boolean().
|
||||
|
@ -229,19 +229,19 @@ mod_opt_type(access_subscribe) ->
|
||||
mod_opt_type(access_publish) ->
|
||||
topic_access_validator();
|
||||
mod_opt_type(queue_type) ->
|
||||
econf:well_known(queue_type, ?MODULE);
|
||||
econf:queue_type();
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(ram_db_type) ->
|
||||
econf:well_known(ram_db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(use_cache) ->
|
||||
econf:well_known(use_cache, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_missed) ->
|
||||
econf:well_known(cache_missed, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
listen_opt_type(tls_verify) ->
|
||||
econf:bool();
|
||||
@ -541,10 +541,7 @@ init_payload_cache(Mod, Host, Opts) ->
|
||||
cache_opts(Opts) ->
|
||||
MaxSize = mod_mqtt_opt:cache_size(Opts),
|
||||
CacheMissed = mod_mqtt_opt:cache_missed(Opts),
|
||||
LifeTime = case mod_mqtt_opt:cache_life_time(Opts) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_mqtt_opt:cache_life_time(Opts),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
-spec use_cache(module(), binary()) -> boolean().
|
||||
|
@ -1016,15 +1016,15 @@ mod_opt_type(default_room_options) ->
|
||||
public_list => econf:bool(),
|
||||
title => econf:binary()});
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(ram_db_type) ->
|
||||
econf:well_known(ram_db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(host) ->
|
||||
econf:well_known(host, ?MODULE);
|
||||
econf:host();
|
||||
mod_opt_type(hosts) ->
|
||||
econf:well_known(hosts, ?MODULE);
|
||||
econf:hosts();
|
||||
mod_opt_type(queue_type) ->
|
||||
econf:well_known(queue_type, ?MODULE).
|
||||
econf:queue_type().
|
||||
|
||||
mod_options(Host) ->
|
||||
[{access, all},
|
||||
|
@ -1140,9 +1140,9 @@ mod_opt_type(limits) ->
|
||||
#{message => econf:non_neg_int(infinite),
|
||||
presence => econf:non_neg_int(infinite)})});
|
||||
mod_opt_type(host) ->
|
||||
econf:well_known(host, ?MODULE);
|
||||
econf:host();
|
||||
mod_opt_type(hosts) ->
|
||||
econf:well_known(hosts, ?MODULE).
|
||||
econf:hosts().
|
||||
|
||||
mod_options(Host) ->
|
||||
[{access, all},
|
||||
|
@ -172,10 +172,7 @@ init_cache(Opts) ->
|
||||
case mod_offline_opt:use_mam_for_storage(Opts) of
|
||||
true ->
|
||||
MaxSize = mod_offline_opt:cache_size(Opts),
|
||||
LifeTime = case mod_offline_opt:cache_life_time(Opts) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_offline_opt:cache_life_time(Opts),
|
||||
COpts = [{max_size, MaxSize}, {cache_missed, false}, {life_time, LifeTime}],
|
||||
ets_cache:new(?EMPTY_SPOOL_CACHE, COpts);
|
||||
false ->
|
||||
@ -1107,11 +1104,11 @@ mod_opt_type(store_empty_body) ->
|
||||
unless_chat_state,
|
||||
econf:bool());
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
mod_options(Host) ->
|
||||
[{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||
|
@ -706,10 +706,7 @@ init_cache(Mod, Host, Opts) ->
|
||||
cache_opts(Opts) ->
|
||||
MaxSize = mod_privacy_opt:cache_size(Opts),
|
||||
CacheMissed = mod_privacy_opt:cache_missed(Opts),
|
||||
LifeTime = case mod_privacy_opt:cache_life_time(Opts) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_privacy_opt:cache_life_time(Opts),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
-spec use_cache(module(), binary()) -> boolean().
|
||||
@ -849,15 +846,15 @@ depends(_Host, _Opts) ->
|
||||
[].
|
||||
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(use_cache) ->
|
||||
econf:well_known(use_cache, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_missed) ->
|
||||
econf:well_known(cache_missed, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
mod_options(Host) ->
|
||||
[{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||
|
@ -93,15 +93,15 @@ depends(_Host, _Opts) ->
|
||||
[{mod_pubsub, soft}].
|
||||
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(use_cache) ->
|
||||
econf:well_known(use_cache, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_missed) ->
|
||||
econf:well_known(cache_missed, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
mod_options(Host) ->
|
||||
[{db_type, ejabberd_config:default_db(Host, ?MODULE)},
|
||||
@ -353,10 +353,7 @@ init_cache(Mod, Host, Opts) ->
|
||||
cache_opts(Opts) ->
|
||||
MaxSize = mod_private_opt:cache_size(Opts),
|
||||
CacheMissed = mod_private_opt:cache_missed(Opts),
|
||||
LifeTime = case mod_private_opt:cache_life_time(Opts) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_private_opt:cache_life_time(Opts),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
-spec use_cache(module(), binary()) -> boolean().
|
||||
|
@ -97,7 +97,7 @@ depends(_Host, _Opts) ->
|
||||
mod_opt_type(access) ->
|
||||
econf:acl();
|
||||
mod_opt_type(hostname) ->
|
||||
econf:well_known(host, ?MODULE);
|
||||
econf:host();
|
||||
mod_opt_type(ip) ->
|
||||
econf:ip();
|
||||
mod_opt_type(name) ->
|
||||
@ -107,11 +107,11 @@ mod_opt_type(port) ->
|
||||
mod_opt_type(max_connections) ->
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(host) ->
|
||||
econf:well_known(host, ?MODULE);
|
||||
econf:host();
|
||||
mod_opt_type(hosts) ->
|
||||
econf:well_known(hosts, ?MODULE);
|
||||
econf:hosts();
|
||||
mod_opt_type(ram_db_type) ->
|
||||
econf:well_known(ram_db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(server_host) ->
|
||||
econf:binary();
|
||||
mod_opt_type(auth_type) ->
|
||||
|
@ -3894,11 +3894,11 @@ mod_opt_type(pep_mapping) ->
|
||||
mod_opt_type(plugins) ->
|
||||
econf:list(econf:binary());
|
||||
mod_opt_type(host) ->
|
||||
econf:well_known(host, ?MODULE);
|
||||
econf:host();
|
||||
mod_opt_type(hosts) ->
|
||||
econf:well_known(hosts, ?MODULE);
|
||||
econf:hosts();
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE).
|
||||
econf:db_type(?MODULE).
|
||||
|
||||
mod_options(Host) ->
|
||||
[{access_createnode, all},
|
||||
|
@ -132,15 +132,15 @@ mod_opt_type(include_body) ->
|
||||
econf:bool(),
|
||||
econf:binary());
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(use_cache) ->
|
||||
econf:well_known(use_cache, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_missed) ->
|
||||
econf:well_known(cache_missed, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
-spec mod_options(binary()) -> [{atom(), any()}].
|
||||
mod_options(Host) ->
|
||||
@ -718,10 +718,7 @@ init_cache(Mod, Host, Opts) ->
|
||||
cache_opts(Opts) ->
|
||||
MaxSize = mod_push_opt:cache_size(Opts),
|
||||
CacheMissed = mod_push_opt:cache_missed(Opts),
|
||||
LifeTime = case mod_push_opt:cache_life_time(Opts) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_push_opt:cache_life_time(Opts),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
-spec use_cache(module(), binary()) -> boolean().
|
||||
|
@ -1130,10 +1130,7 @@ init_cache(Mod, Host, Opts) ->
|
||||
cache_opts(Opts) ->
|
||||
MaxSize = mod_roster_opt:cache_size(Opts),
|
||||
CacheMissed = mod_roster_opt:cache_missed(Opts),
|
||||
LifeTime = case mod_roster_opt:cache_life_time(Opts) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_roster_opt:cache_life_time(Opts),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
-spec use_cache(module(), binary(), roster | roster_version) -> boolean().
|
||||
@ -1220,15 +1217,15 @@ mod_opt_type(store_current_id) ->
|
||||
mod_opt_type(versioning) ->
|
||||
econf:bool();
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(use_cache) ->
|
||||
econf:well_known(use_cache, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_missed) ->
|
||||
econf:well_known(cache_missed, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
mod_options(Host) ->
|
||||
[{access, all},
|
||||
|
@ -1008,7 +1008,7 @@ import(LServer, {sql, _}, DBType, Tab, L) ->
|
||||
Mod:import(LServer, Tab, L).
|
||||
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE).
|
||||
econf:db_type(?MODULE).
|
||||
|
||||
mod_options(Host) ->
|
||||
[{db_type, ejabberd_config:default_db(Host, ?MODULE)}].
|
||||
|
@ -519,10 +519,7 @@ use_cache(_Host, Opts) ->
|
||||
cache_opts(_Host, Opts) ->
|
||||
MaxSize = mod_shared_roster_ldap_opt:cache_size(Opts),
|
||||
CacheMissed = mod_shared_roster_ldap_opt:cache_missed(Opts),
|
||||
LifeTime = case mod_shared_roster_ldap_opt:cache_life_time(Opts) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_shared_roster_ldap_opt:cache_life_time(Opts),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
mod_opt_type(ldap_auth_check) ->
|
||||
@ -581,13 +578,13 @@ mod_opt_type(ldap_uids) ->
|
||||
fun(U) -> {U, <<"%u">>} end)),
|
||||
econf:map(econf:binary(), econf:binary(), [unique]));
|
||||
mod_opt_type(use_cache) ->
|
||||
econf:well_known(use_cache, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_missed) ->
|
||||
econf:well_known(cache_missed, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
-spec mod_options(binary()) -> [{ldap_uids, [{binary(), binary()}]} |
|
||||
{atom(), any()}].
|
||||
|
@ -784,9 +784,9 @@ mod_opt_type(resend_on_timeout) ->
|
||||
if_offline,
|
||||
econf:bool());
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(queue_type) ->
|
||||
econf:well_known(queue_type, ?MODULE).
|
||||
econf:queue_type().
|
||||
|
||||
mod_options(Host) ->
|
||||
[{max_ack_queue, 5000},
|
||||
|
@ -497,10 +497,7 @@ init_cache(Mod, Host, Opts) ->
|
||||
cache_opts(_Host, Opts) ->
|
||||
MaxSize = mod_vcard_opt:cache_size(Opts),
|
||||
CacheMissed = mod_vcard_opt:cache_missed(Opts),
|
||||
LifeTime = case mod_vcard_opt:cache_life_time(Opts) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_vcard_opt:cache_life_time(Opts),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
-spec use_cache(module(), binary()) -> boolean().
|
||||
@ -544,19 +541,19 @@ mod_opt_type(matches) ->
|
||||
mod_opt_type(search) ->
|
||||
econf:bool();
|
||||
mod_opt_type(host) ->
|
||||
econf:well_known(host, ?MODULE);
|
||||
econf:host();
|
||||
mod_opt_type(hosts) ->
|
||||
econf:well_known(hosts, ?MODULE);
|
||||
econf:hosts();
|
||||
mod_opt_type(db_type) ->
|
||||
econf:well_known(db_type, ?MODULE);
|
||||
econf:db_type(?MODULE);
|
||||
mod_opt_type(use_cache) ->
|
||||
econf:well_known(use_cache, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_missed) ->
|
||||
econf:well_known(cache_missed, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
mod_options(Host) ->
|
||||
[{allow_return_all, false},
|
||||
|
@ -160,10 +160,7 @@ init_cache(Host, Opts) ->
|
||||
cache_opts(Opts) ->
|
||||
MaxSize = mod_vcard_xupdate_opt:cache_size(Opts),
|
||||
CacheMissed = mod_vcard_xupdate_opt:cache_missed(Opts),
|
||||
LifeTime = case mod_vcard_xupdate_opt:cache_life_time(Opts) of
|
||||
infinity -> infinity;
|
||||
I -> timer:seconds(I)
|
||||
end,
|
||||
LifeTime = mod_vcard_xupdate_opt:cache_life_time(Opts),
|
||||
[{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}].
|
||||
|
||||
-spec use_cache(binary()) -> boolean().
|
||||
@ -192,13 +189,13 @@ compute_hash(VCard) ->
|
||||
%% Options
|
||||
%%====================================================================
|
||||
mod_opt_type(use_cache) ->
|
||||
econf:well_known(use_cache, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_size) ->
|
||||
econf:well_known(cache_size, ?MODULE);
|
||||
econf:pos_int(infinity);
|
||||
mod_opt_type(cache_missed) ->
|
||||
econf:well_known(cache_missed, ?MODULE);
|
||||
econf:bool();
|
||||
mod_opt_type(cache_life_time) ->
|
||||
econf:well_known(cache_life_time, ?MODULE).
|
||||
econf:timeout(second, infinity).
|
||||
|
||||
mod_options(Host) ->
|
||||
[{use_cache, ejabberd_option:use_cache(Host)},
|
||||
|
@ -389,18 +389,10 @@ spec(either, 2, [F1, F2], Mod) ->
|
||||
erl_types:t_sup([Spec1, Spec2]);
|
||||
spec(and_then, 2, [_, F], Mod) ->
|
||||
spec(Mod, F);
|
||||
spec(well_known, 2, [Form, _], Mod) ->
|
||||
case erl_syntax:atom_value(Form) of
|
||||
queue_type -> spec(queue_type, 0, [], Mod);
|
||||
db_type -> erl_types:t_atom();
|
||||
ram_db_type -> erl_types:t_atom();
|
||||
cache_life_time -> spec(pos_int, 1, [erl_syntax:atom(infinity)], Mod);
|
||||
cache_size -> spec(pos_int, 1, [erl_syntax:atom(infinity)], Mod);
|
||||
use_cache -> spec(bool, 0, [], Mod);
|
||||
cache_missed -> spec(bool, 0, [], Mod);
|
||||
host -> erl_types:t_binary();
|
||||
hosts -> erl_types:t_list(erl_types:t_binary())
|
||||
end;
|
||||
spec(host, 0, _, _) ->
|
||||
erl_types:t_binary();
|
||||
spec(hosts, 0, _, _) ->
|
||||
erl_types:t_list(erl_types:t_binary());
|
||||
spec(options, A, [Form|OForm], Mod) when A == 1; A == 2 ->
|
||||
case erl_syntax:type(Form) of
|
||||
map_expr ->
|
||||
|
Loading…
Reference in New Issue
Block a user