./ct_report/coverage/mongoose_wpool_redis.COVER.html

1 -module(mongoose_wpool_redis).
2 -behaviour(mongoose_wpool).
3
4 -export([init/0]).
5 -export([start/4]).
6 -export([stop/2]).
7 -export([is_supported_strategy/1]).
8
9 %% --------------------------------------------------------------
10 %% mongoose_wpool callbacks
11 -spec init() -> ok.
12 init() ->
13 42 ok.
14
15 -spec start(mongooseim:host_type_or_global(), mongoose_wpool:tag(),
16 mongoose_wpool:pool_opts(), mongoose_wpool:conn_opts()) -> {ok, pid()} | {error, any()}.
17 start(HostType, Tag, WpoolOptsIn, ConnOpts) ->
18 84 ProcName = mongoose_wpool:make_pool_name(redis, HostType, Tag),
19 84 WpoolOpts = wpool_spec(WpoolOptsIn, ConnOpts),
20 84 mongoose_wpool:start_sup_pool(redis, ProcName, WpoolOpts).
21
22 -spec stop(mongooseim:host_type_or_global(), mongoose_wpool:tag()) -> ok.
23 stop(_, _) ->
24 78 ok.
25
26
:-(
is_supported_strategy(available_worker) -> false;
27 84 is_supported_strategy(_) -> true.
28
29 %% --------------------------------------------------------------
30 %%% Internal functions
31 wpool_spec(WpoolOptsIn, ConnOpts) ->
32 84 Worker = {eredis_client, makeargs(ConnOpts)},
33 84 [{worker, Worker} | WpoolOptsIn].
34
35 makeargs(Opts = #{host := _Host, port := _Port, database := _Database, password := _Password}) ->
36 84 proplists:from_map(Opts) ++ [{reconnect_sleep, 100}, {connect_timeout, 5000}].
Line Hits Source