Skip to content

Commit

Permalink
Use is_pid and improve doc (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
preciz authored Jul 25, 2024
1 parent 9a4e113 commit 893d1a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/db_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ defmodule DBConnection do
to allow the checkout or `{:disconnect, exception, state}` to disconnect.
This callback is called immediately after the connection is established
and the state is never effetively checked in again. That's because
and the state is never effectively checked in again. That's because
DBConnection keeps the connection state in an ETS table that is moved
between the different clients checking out connections. There is no
`checkin` callback. The state is only handed back to the connection
Expand Down Expand Up @@ -1274,13 +1274,13 @@ defmodule DBConnection do
end

@doc """
Returns connection module used by the given connection pool.
Returns the connection module used by the given connection pool.
When given a process that is not a connection pool, returns an `:error`.
"""
@spec connection_module(conn) :: {:ok, module} | :error
def connection_module(conn) do
with pid when pid != nil <- pool_pid(conn),
with pid when is_pid(pid) <- pool_pid(conn),
{:dictionary, dictionary} <- Process.info(pid, :dictionary),
{@connection_module_key, module} <- List.keyfind(dictionary, @connection_module_key, 0),
do: {:ok, module},
Expand Down
3 changes: 1 addition & 2 deletions lib/db_connection/ownership.ex
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ defmodule DBConnection.Ownership do
It may return `:ok` if the connection is checked out.
`{:already, :owner | :allowed}` if the caller process already
has a connection, `:error` if it could be not checked out or
raise if there was an error.
has a connection, or raise if there was an error.
"""
@spec ownership_checkout(GenServer.server(), Keyword.t()) ::
:ok | {:already, :owner | :allowed}
Expand Down

0 comments on commit 893d1a6

Please sign in to comment.