                        :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)]}}}}})
+
+  )

           :evmsgs []}
          eventhandlers))

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

          resmsgs (if abort?
                    evmsgs
                    (concat evmsgs (->> (goto-next-and-transform transs [msg])
                                        (map inc-transition-count))))]
      (debug "routing ending with" (mapv printable-msg resmsgs))
      resmsgs)
    (do (warn "dropping message due to high transition-count")
        [])))


