<commit_before>require Logger

defmodule OpenAperture.Fleet.FleetApiInstances do
    
    def start_link(_opts \\ []) do
        Agent.start_link(fn -> %{} end, name: __MODULE__)
    end

    def get_instance(etcd_token) do
        Agent.get_and_update(__MODULE__, fn map ->
          case map[etcd_token] do
            nil -> 
                {:ok, pid} = FleetApi.Etcd.start_link(etcd_token)
                Logger.debug "created new fleet api instance for token #{etcd_token}"
                {pid, Map.put(map, etcd_token, pid)}
            pid ->
                {pid, map}
          end
        end)
    end
end<commit_msg>switch to creating new instances rather than using cached instances<commit_after>require Logger

defmodule OpenAperture.Fleet.FleetApiInstances do
    
  def start_link(_opts \\ []) do
      Agent.start_link(fn -> %{} end, name: __MODULE__)
  end

  def get_instance(etcd_token) do
    Agent.get_and_update(__MODULE__, fn map ->
      case map[etcd_token] do
        nil -> 
          {:ok, pid} = FleetApi.Etcd.start_link(etcd_token)
          Logger.debug "created new fleet api instance for token #{etcd_token}"
          {pid, Map.put(map, etcd_token, pid)}
        pid ->
          {pid, map}
      end
    end)
  end
end
{'fraction_non_alphanumeric': 0.09713375796178345, 'fraction_numerical': 0.0, 'mean_word_length': 2.158291457286432, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6591008', 'n_tokens_mistral': 406, 'n_tokens_neox': 395, 'n_words': 100}