 
   require Logger
 
-  alias ESx.Transport.{State, Sniffer, Connection}
+  alias ESx.Transport.{State, Sniffer, Connection, ServerError}
 
   defstruct [
     method: "GET",

        # connection.healthy! if connection.failures > 0

      # retry_on_status
      {:ok, %HTTPoison.Response{status_code: code}} when code >= 300 ->
        if tries <= s.max_retry and code in s.retry_on_status do
          Logger.debug "retry in #{code} status code."
          do_perform_request method, path, params, body, tries
        else
          {:error, %ServerError{message: "Method #{method} not supported"}}
        end

      # failure
      {:error, %HTTPoison.Error{reason: reason} = perr} ->
        if tries <= s.max_retry do
          Logger.debug reason
          do_perform_request method, path, params, body, tries
        else
          {:error, perr}
        end
    end

    end
  end

  defp do_perform_request(method, path, params, body, tries \\ 0) do
    tries = tries + 1

