diff --git a/lib/ch/connection.ex b/lib/ch/connection.ex index 9ff5074..431ee14 100644 --- a/lib/ch/connection.ex +++ b/lib/ch/connection.ex @@ -65,7 +65,6 @@ defmodule Ch.Connection do @impl true @spec ping(conn) :: {:ok, conn} | {:disconnect, Mint.Types.error() | Error.t(), conn} def ping(conn) do - conn = maybe_reconnect(conn) headers = [{"user-agent", @user_agent}] case request(conn, "GET", "/ping", headers, _body = "", _opts = []) do @@ -103,10 +102,8 @@ defmodule Ch.Connection do @impl true def handle_declare(query, params, opts, conn) do - conn = maybe_reconnect(conn) %Query{command: command, decode: decode} = query {query_params, extra_headers, body} = params - path = path(conn, query_params, opts) headers = headers(conn, extra_headers, opts) timeout = timeout(conn, opts) @@ -267,7 +264,6 @@ defmodule Ch.Connection do @impl true def handle_execute(%Query{} = query, {:stream, params}, opts, conn) do - conn = maybe_reconnect(conn) {query_params, extra_headers, body} = params path = path(conn, query_params, opts) @@ -300,7 +296,6 @@ defmodule Ch.Connection do end def handle_execute(%Query{command: :insert} = query, params, opts, conn) do - conn = maybe_reconnect(conn) {query_params, extra_headers, body} = params path = path(conn, query_params, opts) @@ -319,9 +314,7 @@ defmodule Ch.Connection do end def handle_execute(query, params, opts, conn) do - conn = maybe_reconnect(conn) {query_params, extra_headers, body} = params - path = path(conn, query_params, opts) headers = headers(conn, extra_headers, opts) @@ -482,28 +475,6 @@ defmodule Ch.Connection do "/?" <> URI.encode_query(settings ++ query_params) end - # If the http connection was closed by the server, attempt to - # reconnect once. If the re-connect failed, return the old - # connection and let the error bubble up to the caller. - defp maybe_reconnect(conn) do - if HTTP.open?(conn) do - conn - else - opts = HTTP.get_private(conn, :connect_options) - - with {:ok, new_conn} <- do_connect(opts) do - Logger.warning( - "The connection was closed by the server; a new connection has been successfully reestablished." - ) - - # copy settings that are set dynamically (e.g. json as text) over to the new connection - maybe_put_private(new_conn, :settings, HTTP.get_private(conn, :settings)) - else - _ -> conn - end - end - end - defp do_connect(opts) do scheme = String.to_existing_atom(opts[:scheme] || "http") address = opts[:hostname] || "localhost" diff --git a/mix.exs b/mix.exs index 9392e3d..bdd25e1 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule Ch.MixProject do use Mix.Project @source_url "https://github.com/plausible/ch" - @version "0.6.1" + @version "0.6.2-alpha.1" def project do [