          ::transition-count 0
          ::max-transitions max-transitions))
 
-(defn dispatch [{:keys [components] :as router} msg]
-  (when-let [component (peek (::component msg))]
-    (let [tunnel (get-tunnel router component)
-          dest (or tunnel component)
-          destcomp (get components dest)]
-      (cond (fn? destcomp)                   (destcomp msg)
-            (satisfies? ap/Channel destcomp) (a/put! destcomp msg)
-            (satisfies? p/Tunnel destcomp)   (p/send destcomp msg)
-            true (throw (ex-info "cannot dispatch" {:router router
-                                                    :msg msg
-                                                    :tunnel tunnel
-                                                    :component component
-                                                    :dest dest}))))))
+(defn make-router [ruleset components & {:keys [unit dispatch?]
+                                         :or {dispatch? true}}]
+  {:unit unit
+   :components components
+   :ruleset ruleset
+   :dispatch? dispatch?})
+
 
 #_(defn- process [this req]
   (advance req (:ruleset this)))

    (do (warn "dropping message due to high transition-count")
        [])))

(defn make-router [ruleset components & {:keys [unit dispatch?]
                                         :or {dispatch? true}}]
  {:unit unit
   :components components
   :ruleset ruleset
   :dispatch? dispatch?})

#_(defrecord MessageRouter [ruleset]

  p/Router

  (advance [this msg]
    (advance ruleset msg)))

#_(defn message-router [ruleset]
  (->MessageRouter ruleset))

(defn message [route map & {:keys [max-transitions]
                            :or {max-transitions 100}}]

                  (transform %))
            transitions)
       (apply concat)))

(defn- handle-events [eventhandlers msg]
  (reduce (fn [s [key eventhandler]]
