 
   @doc """
 
-  Wrapper around `GenServer`. Add a new connection in the connections's pool.
+  Wrapper around `GenServer`. Add a new transport in the transports's pool.
 
-  * `conn`    - Process id
-  * `token`   - the token used to identify the connection
-  * `last_id` - the last id received in the connection
+  * `transport`    - Something implementing the `Funnel.Transport` protocol
+  * `token`   - the token used to identify the transport
+  * `last_id` - the last id received in the transport
   """
-  def add(conn, token, last_id \\ nil) do
-    :gen_server.call name(token), {:add, conn, last_id}
+  def add(transport, token, last_id \\ nil) do
+    :gen_server.call name(token), {:add, transport, last_id}
   end
 
   @doc """
 
-  Default values of `Funnel.Transistor`. An empty pool of connections.
+  Default values of `Funnel.Transistor`. An empty pool of transports.
   """
   def init(cache) do
     {:ok, %TransistorState{cache: cache}}


  @doc """

  Writes on each connections the matched document.
  """
  def handle_cast({:notify, id, body}, state) do
    Enum.each(state.connections, fn(conn) -> write(message(id, item), conn) end)
    connections = Enum.reduce(state.connections, [], fn(conn, connections) -> write(connections, conn, response, id) end)
    {:noreply, Map.update!(state, :connections, fn(_) -> connections end) }
  end

  @doc """

  Add a connection to the connections's pool.
  """
  def handle_call({:add, conn, last_id}, _from, state) do
    conn = write_from_cache(conn, state.cache, last_id)
    {:reply, conn, Map.update!(state, :connections, fn(_) -> [conn | state.connections] end) }
  end

  defp name(token) do

  import Funnel.Transport, only: [write: 2]

  defmodule Funnel.TransistorState do
    defstruct cache: nil, transports: []
  end

  alias Funnel.TransistorState
