Fix problems on develop branch
This commit is contained in:
parent
bb09d96f01
commit
61fcfc1184
|
@ -0,0 +1,21 @@
|
||||||
|
language: erlang
|
||||||
|
|
||||||
|
otp_release:
|
||||||
|
- 22.0
|
||||||
|
- 21.3
|
||||||
|
- 20.3
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- git clone https://github.com/erlang/rebar3.git; cd rebar3; ./bootstrap; sudo mv rebar3 /usr/local/bin/; cd ..
|
||||||
|
|
||||||
|
script:
|
||||||
|
- make compile
|
||||||
|
- make xref
|
||||||
|
- make ct
|
||||||
|
- make cover
|
||||||
|
- make dialyzer
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- make coveralls
|
||||||
|
|
||||||
|
sudo: false
|
23
Makefile
23
Makefile
|
@ -1,7 +1,6 @@
|
||||||
.PHONY: deps test
|
.PHONY: deps test
|
||||||
|
|
||||||
BASE_DIR = $(shell pwd)
|
REBAR=rebar3
|
||||||
REBAR=$(BASE_DIR)/rebar
|
|
||||||
|
|
||||||
all: deps compile xref
|
all: deps compile xref
|
||||||
|
|
||||||
|
@ -12,26 +11,16 @@ compile:
|
||||||
@$(REBAR) compile
|
@$(REBAR) compile
|
||||||
|
|
||||||
xref:
|
xref:
|
||||||
@$(REBAR) xref skip_deps=true
|
@$(REBAR) xref
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@$(REBAR) clean
|
@$(REBAR) clean
|
||||||
|
|
||||||
test:
|
ct:
|
||||||
@$(REBAR) skip_deps=true ct
|
@$(REBAR) ct
|
||||||
|
|
||||||
edoc:
|
edoc:
|
||||||
@$(REBAR) doc
|
@$(REBAR) edoc
|
||||||
|
|
||||||
PLT = $(BASE_DIR)/.ecpool_dialyzer.plt
|
|
||||||
APPS = erts kernel stdlib sasl crypto syntax_tools ssl public_key mnesia inets compiler
|
|
||||||
|
|
||||||
check_plt: compile
|
|
||||||
dialyzer --check_plt --plt $(PLT) --apps $(APPS) deps/*/ebin ebin
|
|
||||||
|
|
||||||
build_plt: compile
|
|
||||||
dialyzer --build_plt --output_plt $(PLT) --apps $(APPS) deps/*/ebin ebin
|
|
||||||
|
|
||||||
dialyzer: compile
|
dialyzer: compile
|
||||||
dialyzer -Wno_return --plt $(PLT) deps/*/ebin ebin
|
@$(REBAR) dialyzer
|
||||||
|
|
||||||
|
|
10
rebar.lock
10
rebar.lock
|
@ -1,4 +1,6 @@
|
||||||
[{<<"gproc">>,
|
{"1.1.0",
|
||||||
{git,"git://github.com/uwiger/gproc.git",
|
[{<<"gproc">>,{pkg,<<"gproc">>,<<"0.8.0">>},0}]}.
|
||||||
{ref,"b7b0748d7adaf9b2243921d7e9cf320690eb0544"}},
|
[
|
||||||
0}].
|
{pkg_hash,[
|
||||||
|
{<<"gproc">>, <<"CEA02C578589C61E5341FCE149EA36CCEF236CC2ECAC8691FBA408E7EA77EC2F">>}]}
|
||||||
|
].
|
||||||
|
|
|
@ -76,15 +76,16 @@ set_reconnect_callback(Pool, Callback) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
%% @doc Call the fun with client/connection
|
%% @doc Call the fun with client/connection
|
||||||
-spec(with_client(atom(), fun((Client :: pid()) -> any())) -> any()).
|
-spec(with_client(atom(), fun((Client :: pid()) -> any())) -> no_return()).
|
||||||
with_client(Pool, Fun) when is_atom(Pool) ->
|
with_client(Pool, Fun) when is_atom(Pool) ->
|
||||||
with_worker(gproc_pool:pick_worker(name(Pool)), Fun).
|
with_worker(gproc_pool:pick_worker(name(Pool)), Fun).
|
||||||
|
|
||||||
%% @doc Call the fun with client/connection
|
%% @doc Call the fun with client/connection
|
||||||
-spec(with_client(atom(), any(), fun((Client :: pid()) -> any())) -> any()).
|
-spec(with_client(atom(), any(), fun((Client :: pid()) -> term())) -> no_return()).
|
||||||
with_client(Pool, Key, Fun) when is_atom(Pool) ->
|
with_client(Pool, Key, Fun) when is_atom(Pool) ->
|
||||||
with_worker(gproc_pool:pick_worker(name(Pool), Key), Fun).
|
with_worker(gproc_pool:pick_worker(name(Pool), Key), Fun).
|
||||||
|
|
||||||
|
-spec(with_worker(Worker :: pid(), fun((Client :: pid()) -> any())) -> no_return()).
|
||||||
with_worker(Worker, Fun) ->
|
with_worker(Worker, Fun) ->
|
||||||
case ecpool_worker:client(Worker) of
|
case ecpool_worker:client(Worker) of
|
||||||
{ok, Client} -> Fun(Client);
|
{ok, Client} -> Fun(Client);
|
||||||
|
|
|
@ -65,7 +65,7 @@ start_link(Pool, Id, Mod, Opts) ->
|
||||||
gen_server:start_link(?MODULE, [Pool, Id, Mod, Opts], []).
|
gen_server:start_link(?MODULE, [Pool, Id, Mod, Opts], []).
|
||||||
|
|
||||||
%% @doc Get client/connection.
|
%% @doc Get client/connection.
|
||||||
-spec(client(pid()) -> undefined | pid()).
|
-spec(client(pid()) -> {ok, Client :: pid()} | {error, Reason :: term()}).
|
||||||
client(Pid) ->
|
client(Pid) ->
|
||||||
gen_server:call(Pid, client, infinity).
|
gen_server:call(Pid, client, infinity).
|
||||||
|
|
||||||
|
@ -78,10 +78,6 @@ is_connected(Pid) ->
|
||||||
set_reconnect_callback(Pid, OnReconnect) ->
|
set_reconnect_callback(Pid, OnReconnect) ->
|
||||||
gen_server:cast(Pid, {set_reconn_callbk, OnReconnect}).
|
gen_server:cast(Pid, {set_reconn_callbk, OnReconnect}).
|
||||||
|
|
||||||
-spec(set_reconnect_callback(pid(), ecpool:reconn_callback()) -> ok).
|
|
||||||
set_reconnect_callback(Pid, OnReconnect) ->
|
|
||||||
gen_server:cast(Pid, {set_reconn_callbk, OnReconnect}).
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -103,9 +99,6 @@ handle_call(is_connected, _From, State = #state{client = Client}) ->
|
||||||
IsAlive = Client =/= undefined andalso is_process_alive(Client),
|
IsAlive = Client =/= undefined andalso is_process_alive(Client),
|
||||||
{reply, IsAlive, State};
|
{reply, IsAlive, State};
|
||||||
|
|
||||||
handle_call(is_connected, _From, State = #state{client = Client}) ->
|
|
||||||
{reply, Client =/= undefined, State};
|
|
||||||
|
|
||||||
handle_call(client, _From, State = #state{client = undefined}) ->
|
handle_call(client, _From, State = #state{client = undefined}) ->
|
||||||
{reply, {error, disconnected}, State};
|
{reply, {error, disconnected}, State};
|
||||||
|
|
||||||
|
@ -119,9 +112,6 @@ handle_call(Req, _From, State) ->
|
||||||
handle_cast({set_reconn_callbk, OnReconnect}, State) ->
|
handle_cast({set_reconn_callbk, OnReconnect}, State) ->
|
||||||
{noreply, State#state{on_reconnect = OnReconnect}};
|
{noreply, State#state{on_reconnect = OnReconnect}};
|
||||||
|
|
||||||
handle_cast({set_reconn_callbk, OnReconnect}, State) ->
|
|
||||||
{noreply, State#state{on_reconnect = OnReconnect}};
|
|
||||||
|
|
||||||
handle_cast(_Msg, State) ->
|
handle_cast(_Msg, State) ->
|
||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ t_restart_client(_Config) ->
|
||||||
?debugFmt("~n~p~n", [ecpool:workers(?POOL)]),
|
?debugFmt("~n~p~n", [ecpool:workers(?POOL)]),
|
||||||
?assertEqual(2, length(ecpool:workers(?POOL))),
|
?assertEqual(2, length(ecpool:workers(?POOL))),
|
||||||
ecpool:with_client(?POOL, fun(Client) ->
|
ecpool:with_client(?POOL, fun(Client) ->
|
||||||
test_client:stop(Client, {shutdown, badarg})
|
test_client:stop(Client, badarg)
|
||||||
end),
|
end),
|
||||||
timer:sleep(100),
|
timer:sleep(100),
|
||||||
?debugFmt("~n~p~n", [ecpool:workers(?POOL)]),
|
?debugFmt("~n~p~n", [ecpool:workers(?POOL)]),
|
||||||
|
|
Loading…
Reference in New Issue