       (dosync
         (add (deref current) event)))))
 
-; Take the sum of every event over interval seconds and divide by the interval
-; size.
 (defn rate [interval & children]
+  "Take the sum of every event over interval seconds and divide by the interval
+  size."
   (part-time-fast interval
       (fn [] {:count (ref 0)
               :state (ref {})})

              true)))
        (call-rescue event children)))))

; Passes on events only when their metric falls within the given inclusive
; range. (within [0 1] (fn [event] do-something))
(defn within [r & children]
  (fn [event]
    (when (<= (first r) (:metric_f event) (last r))
      (call-rescue event children))))

            t (or (event :time) (unix-time))]
        (bin event t)))))

; This leaks a thread. Need to think about dynamic scheduling/expiry.
(defn part-time-fast [interval create add finish]
 "Partitions events by time (fast variant). Over interval seconds, adds events
  to a bin, created with (create). When the interval is complete, calls (finish
  bin start-time end-time)"
  (let [current (ref (create))
        start (ref (unix-time))
        switcher (.start (new Thread (bound-fn []
