From 86456b4027e488a473594d1207f3bfd24674a5f2 Mon Sep 17 00:00:00 2001 From: Aphyr Date: Fri, 25 Jan 2013 10:53:29 -0800 Subject: [PATCH] streams/stream -> streams/sdo Closes #133 --- src/riemann/streams.clj | 14 +++++++++++--- test/riemann/test/streams.clj | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/riemann/streams.clj b/src/riemann/streams.clj index e2d56a92c..e050339f6 100644 --- a/src/riemann/streams.clj +++ b/src/riemann/streams.clj @@ -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 diff --git a/test/riemann/test/streams.clj b/test/riemann/test/streams.clj index 6048fe816..cb84de3dc 100644 --- a/test/riemann/test/streams.clj +++ b/test/riemann/test/streams.clj @@ -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]))))