Skip to content

Commit

Permalink
feat: Allow infinite reconnect retries with -1 setting
Browse files Browse the repository at this point in the history
Enable supavisor to maintain connections when the database
is intentionally down. This supports external systems that
dynamically start and scale database instances based on
supavisor metrics, allowing for "scale to zero" scenarios.
  • Loading branch information
kahirokunn committed Jan 24, 2025
1 parent 5a1471f commit 594f4b8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/supavisor/db_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ defmodule Supavisor.DbHandler do
]

maybe_reconnect_callback = fn reason ->
if data.reconnect_retries > @reconnect_retries and data.client_sock != nil,
if @reconnect_retries != -1 and data.reconnect_retries > @reconnect_retries and data.client_sock != nil,
do: {:stop, {:failed_to_connect, reason}},
else: {:keep_state_and_data, {:state_timeout, reconnect_timeout(data), :connect}}
end
Expand Down

0 comments on commit 594f4b8

Please sign in to comment.