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

Proxy info messages to the adapter #316

Merged
merged 8 commits into from
Nov 12, 2024
Merged
Changes from 1 commit
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
20 changes: 15 additions & 5 deletions lib/db_connection/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,22 @@ defmodule DBConnection.Connection do
handle_timeout(s)
end

def handle_event(:info, msg, :no_state, %{mod: mod} = s) do
Logger.info(fn ->
[inspect(mod), ?\s, ?(, inspect(self()), ") missed message: " | inspect(msg)]
end)
def handle_event(:info, msg, :no_state, %{mod: mod, state: state} = s) do
if function_exported?(mod, :handle_info, 2) do
case apply(mod, :handle_info, [msg, state]) do
Copy link
Contributor Author

@ruslandoga ruslandoga Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still passing the state to the callback since the monitor ref / socket ref would be there, and they are probably needed to match on the incoming message.

{:ok, state} ->
pool_update(state, s)
ruslandoga marked this conversation as resolved.
Show resolved Hide resolved

{:disconnect, err, state} ->
{:keep_state, %{s | state: state}, {:next_event, :internal, {:disconnect, {:log, err}}}}
ruslandoga marked this conversation as resolved.
Show resolved Hide resolved
end
else
Logger.info(fn ->
[inspect(mod), ?\s, ?(, inspect(self()), ") missed message: " | inspect(msg)]
end)

handle_timeout(s)
handle_timeout(s)
end
end

@doc false
Expand Down