Fix problems on develop branch

This commit is contained in:
GilbertWong 2019-08-26 16:26:48 +08:00 committed by Gilbert
parent bb09d96f01
commit 61fcfc1184
6 changed files with 38 additions and 35 deletions

21
.travis.yml Normal file
View File

@ -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

View File

@ -1,7 +1,6 @@
.PHONY: deps test
BASE_DIR = $(shell pwd)
REBAR=$(BASE_DIR)/rebar
REBAR=rebar3
all: deps compile xref
@ -12,26 +11,16 @@ compile:
@$(REBAR) compile
xref:
@$(REBAR) xref skip_deps=true
@$(REBAR) xref
clean:
@$(REBAR) clean
test:
@$(REBAR) skip_deps=true ct
ct:
@$(REBAR) ct
edoc:
@$(REBAR) doc
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
@$(REBAR) edoc
dialyzer: compile
dialyzer -Wno_return --plt $(PLT) deps/*/ebin ebin
@$(REBAR) dialyzer

View File

@ -1,4 +1,6 @@
[{<<"gproc">>,
{git,"git://github.com/uwiger/gproc.git",
{ref,"b7b0748d7adaf9b2243921d7e9cf320690eb0544"}},
0}].
{"1.1.0",
[{<<"gproc">>,{pkg,<<"gproc">>,<<"0.8.0">>},0}]}.
[
{pkg_hash,[
{<<"gproc">>, <<"CEA02C578589C61E5341FCE149EA36CCEF236CC2ECAC8691FBA408E7EA77EC2F">>}]}
].

View File

@ -76,15 +76,16 @@ set_reconnect_callback(Pool, Callback) ->
ok.
%% @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_worker(gproc_pool:pick_worker(name(Pool)), Fun).
%% @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_worker(gproc_pool:pick_worker(name(Pool), Key), Fun).
-spec(with_worker(Worker :: pid(), fun((Client :: pid()) -> any())) -> no_return()).
with_worker(Worker, Fun) ->
case ecpool_worker:client(Worker) of
{ok, Client} -> Fun(Client);

View File

@ -65,7 +65,7 @@ start_link(Pool, Id, Mod, Opts) ->
gen_server:start_link(?MODULE, [Pool, Id, Mod, Opts], []).
%% @doc Get client/connection.
-spec(client(pid()) -> undefined | pid()).
-spec(client(pid()) -> {ok, Client :: pid()} | {error, Reason :: term()}).
client(Pid) ->
gen_server:call(Pid, client, infinity).
@ -78,10 +78,6 @@ is_connected(Pid) ->
set_reconnect_callback(Pid, 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
%%--------------------------------------------------------------------
@ -103,9 +99,6 @@ handle_call(is_connected, _From, State = #state{client = Client}) ->
IsAlive = Client =/= undefined andalso is_process_alive(Client),
{reply, IsAlive, State};
handle_call(is_connected, _From, State = #state{client = Client}) ->
{reply, Client =/= undefined, State};
handle_call(client, _From, State = #state{client = undefined}) ->
{reply, {error, disconnected}, State};
@ -119,9 +112,6 @@ handle_call(Req, _From, State) ->
handle_cast({set_reconn_callbk, OnReconnect}, State) ->
{noreply, State#state{on_reconnect = OnReconnect}};
handle_cast({set_reconn_callbk, OnReconnect}, State) ->
{noreply, State#state{on_reconnect = OnReconnect}};
handle_cast(_Msg, State) ->
{noreply, State}.

View File

@ -85,7 +85,7 @@ t_restart_client(_Config) ->
?debugFmt("~n~p~n", [ecpool:workers(?POOL)]),
?assertEqual(2, length(ecpool:workers(?POOL))),
ecpool:with_client(?POOL, fun(Client) ->
test_client:stop(Client, {shutdown, badarg})
test_client:stop(Client, badarg)
end),
timer:sleep(100),
?debugFmt("~n~p~n", [ecpool:workers(?POOL)]),