./ct_report/coverage/mongoose_wpool_riak.COVER.html

1 -module(mongoose_wpool_riak).
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
:-(
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
:-(
ProcName = mongoose_wpool:make_pool_name(riak, HostType, Tag),
19
:-(
WpoolOpts = wpool_spec(WpoolOptsIn, ConnOpts),
20
:-(
mongoose_wpool:start_sup_pool(riak, ProcName, WpoolOpts).
21
22 -spec stop(mongooseim:host_type_or_global(), mongoose_wpool:tag()) -> ok.
23 stop(_, _) ->
24
:-(
ok.
25
26
:-(
is_supported_strategy(available_worker) -> false;
27
:-(
is_supported_strategy(_) -> true.
28
29 %% --------------------------------------------------------------
30 %% Other functions
31
32 wpool_spec(WpoolOptsIn, ConnOpts = #{address := RiakAddr, port := RiakPort}) ->
33
:-(
SecurityOptsKV = prepare_sec_opts(ConnOpts),
34
:-(
RiakPBOpts = [auto_reconnect, keepalive],
35
:-(
WorkerArgs = RiakPBOpts ++ SecurityOptsKV,
36
:-(
Worker = {riakc_pb_socket, [RiakAddr, RiakPort, WorkerArgs]},
37
:-(
[{worker, Worker} | WpoolOptsIn].
38
39 prepare_sec_opts(ConnOpts) ->
40
:-(
lists:flatmap(fun(Opt) -> sec_opts(Opt, ConnOpts) end, [credentials, tls]).
41
42 sec_opts(credentials, #{credentials := #{user := User, password := Password}}) ->
43
:-(
[{credentials, User, Password}];
44 sec_opts(tls, #{tls := TLSOpts = #{cacertfile := CaCertFile}}) ->
45 % riakc_pb_socket requires cacertfile in a separate option
46
:-(
[{cacertfile, CaCertFile}, {ssl_opts, just_tls:make_ssl_opts(TLSOpts)}];
47 sec_opts(_Opt, #{}) ->
48
:-(
[].
Line Hits Source