1 |
|
-module(mongoose_wpool_rabbit). |
2 |
|
-behaviour(mongoose_wpool). |
3 |
|
|
4 |
|
-export([init/0]). |
5 |
|
-export([start/4]). |
6 |
|
-export([stop/2]). |
7 |
|
|
8 |
|
-spec init() -> ok | {error, any()}. |
9 |
|
init() -> |
10 |
:-( |
application:ensure_all_started(amqp_client). |
11 |
|
|
12 |
|
-spec start(mongooseim:host_type_or_global(), mongoose_wpool:tag(), |
13 |
|
mongoose_wpool:pool_opts(), mongoose_wpool:conn_opts()) -> {ok, pid()} | {error, any()}. |
14 |
|
start(HostType, Tag, WpoolOptsIn, ConnOpts) -> |
15 |
:-( |
#{confirms_enabled := Confirms, max_worker_queue_len := MaxQueueLen} = ConnOpts, |
16 |
:-( |
PoolName = mongoose_wpool:make_pool_name(rabbit, HostType, Tag), |
17 |
:-( |
Worker = {mongoose_rabbit_worker, |
18 |
|
[{amqp_client_opts, mongoose_amqp:network_params(ConnOpts)}, |
19 |
|
{host_type, HostType}, |
20 |
|
{pool_tag, Tag}, |
21 |
|
{confirms, Confirms}, |
22 |
|
{max_queue_len, MaxQueueLen}]}, |
23 |
:-( |
WpoolOpts = [{worker, Worker} | WpoolOptsIn], |
24 |
:-( |
mongoose_wpool:start_sup_pool(rabbit, PoolName, WpoolOpts). |
25 |
|
|
26 |
|
-spec stop(mongooseim:host_type_or_global(), mongoose_wpool:tag()) -> ok. |
27 |
|
stop(_, _) -> |
28 |
:-( |
ok. |