 
 (defn handler
   "Send each metric over to the cassandra store"
-  [rollups store]
+  [index rollups insertch]
   (fn [ch info]
-    (siphon (map* (partial formatter rollups) ch)
-            (store/channel-for store))))
+    (siphon (map* (partial index formatter rollups) ch) insertch)))
 
 (defn start
   "Start a tcp carbon listener"
-  [{:keys [store carbon]}]
-  (let [handler (handler (:rollups carbon) store)]
+  [{:keys [store carbon index]}]
+  (let [insertch (store/channel-for store)
+        handler  (handler index (:rollups carbon) insertch)]
     (info "starting carbon handler")
     (tcp/start-tcp-server
      handler

(defn formatter
  "Split each line on whitespace, discard nan metric lines
   and format correct lines for each resolution"
  [rollups input]
  (let [[path metric time] (s/split (.trim input) #" ")]
    (when (not= metric "nan")
      (for [{:keys [rollup period rollup-to]} rollups]
        {:path   path
         :rollup rollup

  (:require [aleph.tcp                  :as tcp]
            [clojure.string             :as s]
            [org.spootnik.cyanite.store :as store]
            [org.spootnik.cyanite.path  :as path]
            [clojure.tools.logging      :refer [info debug]]
            [gloss.core                 :refer [string]]
            [lamina.core                :refer [receive-all map* siphon]]))
