Skip to content

Commit

Permalink
streams/stream -> streams/sdo
Browse files Browse the repository at this point in the history
Closes #133
  • Loading branch information
aphyr committed Jan 25, 2013
1 parent bda0109 commit 86456b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/riemann/streams.clj
Expand Up @@ -128,13 +128,21 @@
(fn [event]
(call-rescue (swap! acc f event) children)))))

(defn stream
"Takes a list of functions f1, f2, f3, and returns f such
that (f event) calls (f1 event) (f2 event) (f3 event)."
(defn sdo
"Takes a list of functions f1, f2, f3, and returns f such that (f event)
calls (f1 event) (f2 event) (f3 event). Useful for binding several streams to
a single variable.
(sdo prn (rate 5 index))"
[& children]
(fn [event]
(call-rescue event children)))

(defn stream
[& args]
(deprecated "riemann.streams/stream is now riemann.streams/sdo."
(apply sdo args)))

(defn moving-event-window
"A sliding window of the last few events. Every time an event arrives, calls
children with a vector of the last n events, from oldest to newest. Ignores
Expand Down
4 changes: 2 additions & 2 deletions test/riemann/test/streams.clj
Expand Up @@ -81,12 +81,12 @@
(deftest smap-test
(test-stream (smap inc) [6 3 -1] [7 4 0]))

(deftest stream-test
(deftest sdo-test
(let [vals1 (atom [])
vals2 (atom [])
add1 #(swap! vals1 conj %)
add2 #(swap! vals2 conj %)]
(run-stream (stream add1 add2) [1 2 3])
(run-stream (sdo add1 add2) [1 2 3])
(is (= @vals1 [1 2 3]))
(is (= @vals2 [1 2 3]))))

Expand Down

0 comments on commit 86456b4

Please sign in to comment.