fix(types): fix types define error

This commit is contained in:
JianBo He 2020-07-16 16:27:12 +08:00 committed by tigercl
parent a47f6e23bc
commit 4cb6c31918
2 changed files with 9 additions and 16 deletions

View File

@ -91,16 +91,22 @@ add_reconnect_callback(Pool, Callback) ->
ok.
%% @doc Call the fun with client/connection
-spec(with_client(atom(), fun((Client :: pid()) -> any())) -> no_return()).
-spec(with_client(atom(), fun((Client :: pid()) -> Ret))
-> Ret | {error, term()}
when Ret :: term()).
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()) -> term())) -> no_return()).
-spec(with_client(atom(), any(), fun((Client :: pid()) -> Ret))
-> Ret | {error, term()}
when Ret :: term()).
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()).
-spec(with_worker(Worker :: pid(), fun((Client :: pid()) -> Ret))
-> Ret | {error, term()}
when Ret :: term()).
with_worker(Worker, Fun) ->
case ecpool_worker:client(Worker) of
{ok, Client} -> Fun(Client);

View File

@ -51,22 +51,9 @@
%% Callback
%%--------------------------------------------------------------------
-ifdef(use_specs).
-callback(connect(ConnOpts :: list())
-> {ok, pid()} | {error, Reason :: term()}).
-else.
-export([behaviour_info/1]).
behaviour_info(callbacks) ->
[{connect, 1}];
behaviour_info(_Other) ->
undefined.
-endif.
%%--------------------------------------------------------------------
%% API
%%--------------------------------------------------------------------