Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use is_pid and improve doc #313

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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