Skip to content

Commit

Permalink
Removed within, without and combine
Browse files Browse the repository at this point in the history
All of these were deprecated in 2014 and I think can now be safely
removed.
  • Loading branch information
jamtur01 committed May 28, 2016
1 parent 37208e8 commit c677342
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 74 deletions.
7 changes: 7 additions & 0 deletions CHANGES.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Unreleased

## Deprecations and API changes

- Removed deprecated functions: `within`, `without` and `combine`. These
were deprecated in 2014.

# Version 0.2.11

This update includes a variety of bug fixes and improvements. Also
Expand Down
29 changes: 0 additions & 29 deletions src/riemann/streams.clj
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,6 @@
(when-not (nil? value)
(call-rescue value children)))))

(defn combine
"Returns a function which takes a seq of events.
Combines events with f, then forwards the result to children."
[f & children]
(deprecated "combine is deprecated in favor of smap or smap*"
(apply smap* f children)))

(defn smapcat
"Streaming mapcat. Calls children with each event in (f event), which should
return a sequence. For instance, to set the state of any services with
Expand Down Expand Up @@ -1578,28 +1571,6 @@
`(by [:host :service]
(changed :state ~@children)))

(defn within
"Passes on events only when their metric falls within the given inclusive
range.
(within [0 1] (fn [event] do-something))"
[r & children]
(deprecated "streams/within is deprecated; use (where (< x metric y))"
(fn stream [event]
(when-let [m (:metric event)]
(when (<= (first r) m (last r))
(call-rescue event children))))))

(defn without
"Passes on events only when their metric falls outside the given (inclusive)
range."
[r & children]
(deprecated "streams/without is deprecated; use (where (not (< x metric y)))"
(fn stream [event]
(when-let [m (:metric event)]
(when-not (<= (first r) m (last r))
(call-rescue event children))))))

(defn over
"Passes on events only when their metric is greater than x"
[x & children]
Expand Down
45 changes: 0 additions & 45 deletions test/riemann/streams_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,6 @@
[& metrics]
(vec (map (fn [m] {:metric m}) metrics)))

(deftest combine-test
(logging/suppress
["riemann.streams"]
(let [r (atom nil)
sum (combine folds/sum (register r))
min (combine folds/minimum (register r))
max (combine folds/maximum (register r))
mean (combine folds/mean (register r))
median (combine folds/median (register r))
events [{:metric 1}
{:metric 0}
{:metric -2}]]
(sum events)
(is (= (deref r) {:metric -1}))
(min events)
(is (= (deref r) {:metric -2}))
(max events)
(is (= (deref r) {:metric 1}))
(mean events)
(is (= (deref r) {:metric -1/3}))
(median events)
(is (= (deref r) {:metric 0})))))

(deftest smap*-test
(testing "passes nil values"
(test-stream (smap* identity)
Expand Down Expand Up @@ -1129,28 +1106,6 @@
(s event))
(is (= 6 (deref i)))))

(deftest within-test
(logging/suppress ["riemann.streams"]
(let [output (ref [])
r (within [1 2]
(fn [e] (dosync (alter output conj e))))
metrics [0.5 1 1.5 2 2.5]
expect [1 1.5 2]]

(doseq [m metrics] (r {:metric m}))
(is (= expect (vec (map (fn [s] (:metric s)) (deref output))))))))

(deftest without-test
(logging/suppress ["riemann.streams"]
(let [output (ref [])
r (without [1 2]
(fn [e] (dosync (alter output conj e))))
metrics [0.5 1 1.5 2 2.5]
expect [0.5 2.5]]

(doseq [m metrics] (r {:metric m}))
(is (= expect (vec (map (fn [s] (:metric s)) (deref output))))))))

(deftest over-test
(logging/suppress ["riemann.streams"]
(let [output (ref [])
Expand Down

0 comments on commit c677342

Please sign in to comment.