This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-13
Channels
- # beginners (28)
- # boot (3)
- # clara (9)
- # cljs-dev (127)
- # clojure (82)
- # clojure-belgium (3)
- # clojure-italy (7)
- # clojure-russia (2)
- # clojure-spec (4)
- # clojure-uk (2)
- # clojurescript (351)
- # data-science (3)
- # datascript (1)
- # datomic (24)
- # fulcro (15)
- # jobs (3)
- # juxt (16)
- # off-topic (2)
- # onyx (18)
- # parinfer (1)
- # pedestal (3)
- # perun (6)
- # re-frame (14)
- # spacemacs (20)
I'm interested in how Clara (or rule engines more generally) would work in an environment where a relational database is used as the repository of all information.
I'm only learning about this stuff so I could be missing something obvious.
Perhaps the key is not letting anyone directly write to the database which would bypassing the rule engine causing it to get out of sync with reality.
A simple "typical architecture" might answer my question.
(let [matched (dsl/parse-rule
[[:eav
(= ?attribute (:attribute this))
(= ?attribute_value (:attribute_value this))
(= ?id (:id this))]]
(insert! {:type ?attribute :id ?id :value ?attribute_value}))
unscreened (dsl/parse-rule
[[:state
(= (:value this) 2)
(= ?id (:id this))]
[:milestone
(= (:value this) -1)
(= ?id (:id this))]]
(insert! {:type :unscreened :id ?id}))
type-query (dsl/parse-query [] [[?unscreened <- :unscreened]])
session (mk-session [matched unscreened type-query] :fact-type-fn :type :cache false)]
(time (-> session
(insert {:type :eav :attribute :state :attribute_value 2 :id 33695360})
(insert {:type :eav :attribute :milestone :attribute_value -1 :id 33695360})
fire-rules
(insert {:type :eav :attribute :milestone :attribute_value 123456 :id 33695360})
fire-rules
(query type-query))))