This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-08
Channels
- # aws (21)
- # beginners (62)
- # boot (29)
- # chestnut (1)
- # cider (110)
- # cljs-dev (37)
- # clojure (93)
- # clojure-berlin (1)
- # clojure-dev (10)
- # clojure-greece (4)
- # clojure-italy (5)
- # clojure-new-zealand (1)
- # clojure-spec (6)
- # clojure-uk (46)
- # clojurebridge (1)
- # clojurescript (54)
- # cryogen (1)
- # cursive (22)
- # datomic (72)
- # emacs (2)
- # events (3)
- # flambo (1)
- # hoplon (88)
- # jobs (6)
- # juxt (51)
- # lein-figwheel (1)
- # leiningen (3)
- # lumo (12)
- # mount (4)
- # off-topic (3)
- # onyx (3)
- # pedestal (4)
- # portkey (27)
- # re-frame (13)
- # reagent (1)
- # ring (4)
- # rum (2)
- # uncomplicate (1)
- # unrepl (3)
tarting file watcher (CTRL-C to quit)... Retrieving clojure-1.3.0-alpha6.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.3.0-alpha7.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.3.0-alpha8.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.3.0-beta2.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.3.0-beta3.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.3.0-RC0.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.4.0-alpha1.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.4.0-alpha2.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.4.0-alpha3.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.4.0-alpha4.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.4.0-alpha5.pom from https://repo1.maven.org/maven2/ (5
wistb that's a little unusual but doesn't necessarily indicate a problem, notice how it's downloading just .poms.
is there a nice solution to having a cell act as a reference in one forumla and as a cell in another?
For example, let’s say I have
(defc indicator 1)
(defc= bad? (> indicator 5))
(defc= alert (when bad? (println "BAD: " indicator)))
I’d only like to trigger the alert when bad?
changes state, but I’d also like to take the current value of the indicatorit’s easy to do by making another ref (e.g. atom) indicator*
which watches and changes together with the indicator
or simply getting a read-only ref
view of a cell, something like
(defc= alert (when bad? (println "BAD: " (->ref indicator))))
i think the closest thing is do-watch
i can imagine a cell= variant that takes a do-watch function, kind of like the way refs already take validation fns
oh, by cell= i mean, a macro/function you create and name for yourself :-)
didn't mean overload cell= more
@dm3 usually I just use and
within my cells
Which solves the "trigger by watching other cell"
@flyboarder not sure how that helps
@dm3 maybe i dont understand the question, what is the problem with your example?
you could be using an anonymous cell instead
does this not work for you:
(cell= (when bad? (println "BAD: " indicator)))
ah so you want a debounce cell
one that only triggers once or so but when your conditions have changed
i think we wrote that somewhere previously
as per my example - the indicator
cell is active when determining the value of bad?
but passive when used inside the alert
so you dont want indicator
to change once bad?
is true?
I’m following now, I dont think this is currently possible due to how the formula is walked
can I ask what the issue is with the indicator triggering the formula?
I’m basically doing https://prometheus.io/docs/alerting/rules/ via Javelin
the use case might be rare enough to be solved without introducing additional concepts to Javelin
@dm3 can the indicator continue to change once the alert function is called?
is that why you only want one value?
personally I use your example all the time
(def alert ((formula #(when % (println "BAD: " @indicator))) bad?)) just came to mind
i guess formula-of cleans that up a tad
yeah, the only issue is with the macro where you have to introduce something to affect hoisting
maybe ~ in cell= can achieve it somehow?
i've forgotten again how that works
ah yes
so ~@indicator is what you want?
this works:
(defn ->ref [c] (let [a (atom @c)] (add-watch c (gensym) (fn [_ _ _ n] (reset! a n))) a))
(defc indicator 1)
(defc= bad? (> indicator 5))
(defc= alert (when bad? (println "BAD" @~(->ref indicator))))
are you sure you need the intermediate atom?
i wonder about (defn ->ref [c] (deref c))
and then (->ref ~indicator)
it either needs to be 1) embedded within the formula with @indicator
2) passed in a way where it’s not recognized by cell?
predicate
maybe cell= could understand some meta on symbols
so you could do like (cell= {:x x :y ^passive y})
i'm kind of into it because then it becomes the inverse of formula-of hehe
formula-of-not
...formula-except
hm, i need to update the templates i think
:thumbsup: