                        :ch-in ch-in
                        :ch-out ch-out
                        :ruleset ruleset}))
+
+
+
+(comment
+
+  (def ruleset1
+    ;;; you can have many routes
+    {:routes
+
+     ;;; defining a route :book-flight
+     {:book-flight
+
+      ;;; routes define transitions from one "component" to other "component(s)"
+      {:transitions {nil :auth-checker
+
+                     :auth-checker {:next :overbooked-checker}
+
+                     :overbooked-checker {:next (fn [msg] :booker)}
+
+                     :booker {:transform (fn [msg] (assoc msg :checked true))
+                              :next [:invoice-generator (fn [msg] :notifier)]}}}}})
+
+  )

            [ow.starbuck.core :refer [defcomponentrecord] :as oc]))

(defn- printable-msg [msg]
  (select-keys msg #{:route :comp :starbuck/route-count}))

(defn- inc-route-count [msg]
  (update msg :starbuck/route-count
          #(inc (or % 0))))

(defn- next->fns [m]

           :evmsgs []}
          eventhandlers))

(defn message [route map & {:keys [max-transitions]
                            :or {max-transitions 100}}]
  "Creates a new routable message."
  (assoc map
         ::route route
         ::component nil
         ::transition-count 0
         ::max-transitions max-transitions))

(defn advance [ruleset msg]
  "Takes a message, runs it against ruleset and returns a sequence of routed messages."
  (debug "routing starting with" (printable-msg msg))
  (if (< (::transition-count msg) 100)
    (let [route (get-in ruleset [:routes (::route msg)])
          trans (get-in route [:transitions (::component msg)])
          transs (if (sequential? trans)
                   trans
                   [trans])
