 (ns kierros.core
   "Cycle-flavoured core functions."
-  (:require [clojure.core.async :as a :refer [<! chan]]
+  (:require [clojure.core.async :as a :refer [<! chan close!]]
             [taoensso.timbre :refer [info]]))
 
 (defn sink-proxies

(defn weld-cycle!
  "Closes the cycle between the sinks and sink-proxies."
  [sink-chans sink-proxy-chans]
  (->> sink-chans
       (map (fn [[key sink-chan]]
              (when sink-chan
                (a/pipe sink-chan (key sink-proxy-chans)))))
       (dorun)))

(defn run
  "Cycle.run equivalent. Accepts a main function and a map of drivers."
  [main drivers]
  (let [sink-proxy-chans (sink-proxies drivers)
        source-chans     (call-drivers drivers sink-proxy-chans)
        sink-chans       (main source-chans)
        _                (weld-cycle! sink-chans sink-proxy-chans)]
    (info "cycle running")))
  [drivers]
  (->> drivers
       keys
       (map (fn [name] [name (chan 10)]))
       (into {})))

(defn call-drivers
