Skip to content

Commit

Permalink
Add defaults for LDAP connection opts in config
Browse files Browse the repository at this point in the history
  • Loading branch information
gustawlippa committed Feb 14, 2022
1 parent 764b43c commit 23d6a4c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/config/mongoose_config_spec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,13 @@ outgoing_pool_connection(<<"ldap">>) ->
wrap = {kv, tls_options},
process = fun ?MODULE:process_tls_sni/1}
},
format_items = map
format_items = map,
include = always,
defaults = #{<<"rootdn">> => "",
<<"password">> => "",
<<"encrypt">> => none,
<<"servers">> => ["localhost"],
<<"connect_interval">> => 10000}
};
outgoing_pool_connection(<<"rabbit">>) ->
#section{
Expand Down
22 changes: 17 additions & 5 deletions test/config_parser_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -753,20 +753,32 @@ pgsql_access() ->
register => [#{acl => all, value => allow}],
s2s_shaper => [#{acl => all, value => fast}]}.

merge_with_default_pool_config(PoolIn) ->
DefaultConfig = #{opts := DefaultOpts} = default_pool_config(),
merge_with_default_pool_config(PoolIn = #{type := Type}) ->
DefaultConfig = #{opts := DefaultOpts, conn_opts := DefaultConnOpts} = default_pool_config(Type),
WpoolOptsWithDefaults = maps:merge(DefaultOpts, maps:get(opts, PoolIn, #{})),
maps:merge(DefaultConfig, PoolIn#{opts => WpoolOptsWithDefaults}).
ConnOptsWithDefaults = maps:merge(DefaultConnOpts, maps:get(conn_opts, PoolIn, #{})),
maps:merge(DefaultConfig, PoolIn#{opts => WpoolOptsWithDefaults,
conn_opts => ConnOptsWithDefaults}).

default_pool_config() ->
default_pool_config(Type) ->
#{scope => global,
opts => default_pool_wpool_opts()}.
opts => default_pool_wpool_opts(),
conn_opts => default_pool_conn_opts(Type)}.

default_pool_wpool_opts() ->
#{workers => 10,
strategy => best_worker,
call_timeout => 5000}.

default_pool_conn_opts(ldap) ->
#{rootdn => "",
password => "",
encrypt => none,
servers => ["localhost"],
connect_interval => 10000};
default_pool_conn_opts(Type) ->
#{}.

default_mod_config(mod_adhoc) ->
#{iqdisc => one_queue,
report_commands_node => false};
Expand Down

0 comments on commit 23d6a4c

Please sign in to comment.