1 |
|
-module(mongoose_wpool_elastic). |
2 |
|
-behaviour(mongoose_wpool). |
3 |
|
|
4 |
|
-export([init/0]). |
5 |
|
-export([start/4]). |
6 |
|
-export([stop/2]). |
7 |
|
|
8 |
|
%% -------------------------------------------------------------- |
9 |
|
%% mongoose_wpool callbacks |
10 |
|
init() -> |
11 |
:-( |
tirerl:start(), |
12 |
:-( |
ok. |
13 |
|
|
14 |
|
start(HostType, Tag, WpoolOptsIn, ConnOpts) -> |
15 |
:-( |
ElasticHost = proplists:get_value(host, ConnOpts, "localhost"), |
16 |
:-( |
Port = proplists:get_value(port, ConnOpts, 9200), |
17 |
:-( |
ProcName = mongoose_wpool:make_pool_name(elastic, HostType, Tag), |
18 |
:-( |
Opts = [{host, list_to_binary(ElasticHost)}, {port, Port}], |
19 |
:-( |
WPoolOptions = [{overrun_warning, infinity}, |
20 |
|
{overrun_handler, {error_logger, warning_report}}, |
21 |
|
{worker, {tirerl_worker, Opts}} |
22 |
|
| WpoolOptsIn], |
23 |
:-( |
case mongoose_wpool:start_sup_pool(elastic, ProcName, WPoolOptions) of |
24 |
|
{ok, Pid} -> |
25 |
:-( |
{external, Pid}; |
26 |
|
Other -> |
27 |
:-( |
Other |
28 |
|
end. |
29 |
|
|
30 |
|
stop(_, _) -> |
31 |
:-( |
ok. |
32 |
|
|