TD-927: small fix

This commit is contained in:
ttt161 2024-09-12 10:57:34 +03:00
parent 16d9505aad
commit bf3397eca2
2 changed files with 5 additions and 4 deletions

View File

@ -24,7 +24,7 @@ query({error, _} = Err, _Pool, _Stmt, _Params) ->
Err;
query(Conn, Pool, Stmt, Params) when is_pid(Conn) ->
Result = epgsql:equery(Conn, Stmt, Params),
_ = epg_pool_mgr:checkin(Pool, self(), Conn),
ok = epg_pool_mgr:checkin(Pool, self(), Conn),
Result.
transaction(Pool, Fun) when is_atom(Pool) ->
@ -38,7 +38,7 @@ transaction({error, _} = Err, _Pool, _Fun) ->
Err;
transaction(Conn, Pool, Fun) when is_pid(Conn) ->
Result = epgsql:with_transaction(Conn, Fun),
_ = epg_pool_mgr:checkin(Pool, self(), Conn),
ok = epg_pool_mgr:checkin(Pool, self(), Conn),
Result.
with(Pool, Fun) when is_atom(Pool) ->
@ -50,5 +50,5 @@ with(empty, _Pool, _F) ->
{error, overload};
with(Conn, Pool, Fun) when is_pid(Conn) ->
Result = Fun(Conn),
_ = epg_pool_mgr:checkin(Pool, self(), Conn),
ok = epg_pool_mgr:checkin(Pool, self(), Conn),
Result.

View File

@ -15,7 +15,8 @@ start_link(PoolName, DbParams, Size, _N) ->
init([PoolName, DbParams, Size]) ->
erlang:process_flag(trap_exit, true),
{ok, #epg_pool_wrk_state{pool = PoolName, params = DbParams, size = Size}, {continue, init}}.
State0 = #epg_pool_wrk_state{pool = PoolName, params = DbParams, size = Size},
{ok, connect(State0)}.
handle_continue(init, State) ->
{noreply, connect(State)}.