Skip to content

Commit

Permalink
fix: some compilation warnings about unused stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
hauleth committed Aug 22, 2024
1 parent e25eaac commit 6c8c2f1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 32 deletions.
2 changes: 0 additions & 2 deletions lib/supavisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ defmodule Supavisor do

require Logger

import Cachex.Spec

alias Supavisor.{
Helpers,
Manager,
Expand Down
1 change: 0 additions & 1 deletion lib/supavisor/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ defmodule Supavisor.Application do

require Logger

alias Supavisor.Handlers.Proxy.Handler, as: ProxyHandler
alias Supavisor.Monitoring.PromEx

@metrics_disabled Application.compile_env(:supavisor, :metrics_disabled, false)
Expand Down
33 changes: 4 additions & 29 deletions lib/supavisor/client_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,10 @@ defmodule Supavisor.ClientHandler do
{:next_state, :idle, %{data | db_pid: db_pid, stats: stats}, handle_actions(data)}

:read_sql_error ->
Logger.error("ClientHandler: read only sql transaction, reruning the query to write pool")
Logger.error(
"ClientHandler: read only sql transaction, rerunning the query to write pool"
)

# release the read pool
_ = handle_db_pid(data.mode, data.pool, data.db_pid)

Expand Down Expand Up @@ -991,34 +994,6 @@ defmodule Supavisor.ClientHandler do
end
end

@spec handle_prepared_statements({pid, pid}, binary, map) :: :ok | nil
defp handle_prepared_statements({_, pid}, bin, %{mode: :transaction} = data) do
with {:ok, payload} <- Client.get_payload(bin),
{:ok, statements} <- Supavisor.PgParser.statements(payload),
true <- statements in [["PrepareStmt"], ["DeallocateStmt"]] do
Logger.info("ClientHandler: Handle prepared statement #{inspect(payload)}")

GenServer.call(data.pool, :get_all_workers)
|> Enum.each(fn
{_, ^pid, _, [Supavisor.DbHandler]} ->
Logger.debug("ClientHandler: Linked DbHandler #{inspect(pid)}")
nil

{_, pool_proc, _, [Supavisor.DbHandler]} ->
Logger.debug(
"ClientHandler: Sending prepared statement change #{inspect(payload)} to #{inspect(pool_proc)}"
)

send(pool_proc, {:handle_ps, payload, bin})
end)
else
error ->
Logger.debug("ClientHandler: Skip prepared statement #{inspect(error)}")
end
end

defp handle_prepared_statements(_, _, _), do: nil

@spec handle_actions(map) :: [{:timeout, non_neg_integer, atom}]
defp handle_actions(%{} = data) do
heartbeat =
Expand Down

0 comments on commit 6c8c2f1

Please sign in to comment.