 #
 
 defmodule Instrumental.Connection do
+  defmodule State do
+    defstruct sock: nil, state: nil
+
+    @type t :: %{
+      sock: pid,
+      state: connection_state
+    }
+
+    @type connection_state :: :hello | :connected | :auth
+  end
+
   alias Instrumental.Protocol
   alias Instrumental.Config
 


  def init([]) do
    if Config.enabled? do
      {:ok, sock} = :gen_tcp.connect(Config.host, Config.port, [mode: :binary, packet: 0, active: false, keepalive: true])
      {:ok, %{sock: sock, state: nil}, 0}
    else
      :ignore
    end

    :gen_tcp.close(sock)
    :ok
  end

  #
  # Private
  #

  defp connect do
    :gen_tcp.connect(Config.host, Config.port, [mode: :binary, packet: 0, active: false, keepalive: true])
  end
end
