(apply-additions-to-store in)
Reads ops from channel and applies additions to store
Reads ops from channel and applies additions to store
(apply-removals-to-store in)
Reads ops from in channel and applies removals to store
Reads ops from in channel and applies removals to store
(batch-complete? event batch)
Returns true if the event is fire rules complete or it exists in the batch and
the maximum event number received is equal to :total-events
from fire rules complete
Returns true if the event is fire rules complete or it exists in the batch and the maximum event number received is equal to `:total-events` from fire rules complete
(create-change-report-ch)
(create-change-report-ch f)
Returns core.async channel with operational changes from session. Removes Precept implementation facts when called with no arguments. May be called with a function that will be applied to all :added and :removed facts.
Usage:
(def nil-values-ch
(create-changes-report-ch
(filter (fn [{:keys [e a v t]} record] (nil? v))
%)))
(go-loop []
(let [changes (<! nil-values-ch)]
(println "Facts with nil values added / removed:" changes)))
=> Facts with nil values added / removed: {:added () :removed ()}
Returns core.async channel with operational changes from session. Removes Precept implementation facts when called with no arguments. May be called with a function that will be applied to all :added and :removed facts. Usage: ```clj (def nil-values-ch (create-changes-report-ch (filter (fn [{:keys [e a v t]} record] (nil? v)) %))) (go-loop [] (let [changes (<! nil-values-ch)] (println "Facts with nil values added / removed:" changes))) => Facts with nil values added / removed: {:added () :removed ()} ```
(create-dto>socket-router in send! encoding)
Returns a go-loop that takes from a channel with events emitted by
precept.listeners/PersistentSessionEventMessager and calls the provided send function, intended for use with a precept-devtools socket. Batches events per call to
fire-rules`.
Returns a go-loop that takes from a channel with events emitted by `precept.listeners/PersistentSessionEventMessager and calls the provided send function, intended for use with a precept-devtools socket. Batches events per call to `fire-rules`.
(create-fired-session-ch)
Returns core.async channel that receives the session after the rules have been fired and before its listener has been replaced.
Returns core.async channel that receives the session after the rules have been fired and before its listener has been replaced.
(identical-conditions-and-consequences-error {:keys [existing-name type]})
(init-transactor)
Parks until session is initialized in (:session precept.state/state) then spawns
a transactor that takes from action-ch
.
Parks until session is initialized in (:session precept.state/state) then spawns a transactor that takes from `action-ch`.
(matching-conditions-and-consequences lhs rhs rules-index)
(read-changes-from-session in)
Reads changes from session channel, fires rules, and puts resultant changes on changes channel. Updates session state atom with new session. Changes are returned keyed by :added, :removed as Tuple records.
Reads changes from session channel, fires rules, and puts resultant changes on changes channel. Updates session state atom with new session. Changes are returned keyed by :added, :removed as Tuple records.
(register req)
Should only get called by subscribe
, which determines if a sub exists.
Generates an id used to track requests and responses throughout the system.
req
is a vector of name and params (currently we just support a name).
Inserts subscription request into the current session. Responses are generated by subscription
handler rules that match request name and insert facts into working memory.
Subscriptions are stored in (:subscriptions @state). The lens is a reagent cursor that
observes changes to the subscription's response that is written to the store.
Should only get called by `subscribe`, which determines if a sub exists. Generates an id used to track requests and responses throughout the system. `req` is a vector of name and params (currently we just support a name). Inserts subscription request into the current session. Responses are generated by subscription handler rules that match request name and insert facts into working memory. Subscriptions are stored in (:subscriptions @state). The lens is a reagent cursor that observes changes to the subscription's response that is written to the store.
Returns rule name if found in registry, else registers new rule and returns name
Returns rule name if found in registry, else registers new rule and returns name
(resume! {:keys [session facts devtools] :as options})
Resets session with provided facts if start!
has been called, otherwise returns the session
received as an argument unmodified. Avoids duplicate session creation on page refresh in
development when there is stale session metadata in the compiler.
Resets session with provided facts if `start!` has been called, otherwise returns the session received as an argument unmodified. Avoids duplicate session creation on page refresh in development when there is stale session metadata in the compiler.
(start! {:keys [id session facts devtools] :as options})
Initializes session with facts.
:session
- Instance of clara.rules.engine.LocalSession created by precept.rules/session
:id
- Value that uniquely identifies the session.:facts
- Vector. Initial facts to be inserted into the session:devtools
(optional) - Boolean or map of options for connecting to a
running instance of a Precept devtools server. Default: nil
.
Supported devtools options:
:host
- String with host and port separated by :
.
Defaults to default Devtools server address and port 0.0.0.0:3232
.:path
- String of path for server socket.
Defaults to default Devtools server path /chsk
.:encoding
- Keyword of encoding for devtools socket.
One of transit enc-types: :json
, :json-verbose
. Defaults to
:json-verbose
.Initializes session with facts. - `:session` - Instance of clara.rules.engine.LocalSession created by `precept.rules/session` - `:id` - Value that uniquely identifies the session. - `:facts` - Vector. Initial facts to be inserted into the session - `:devtools` (optional) - Boolean or map of options for connecting to a running instance of a Precept devtools server. Default: `nil`. Supported devtools options: - `:host` - String with host and port separated by `:`. Defaults to default Devtools server address and port `0.0.0.0:3232`. - `:path` - String of path for server socket. Defaults to default Devtools server path `/chsk`. - `:encoding` - Keyword of encoding for devtools socket. One of transit enc-types: `:json`, `:json-verbose` . Defaults to `:json-verbose`.
(subscribe req)
Returns lens that points to a path in the store. Sub is handled by a rule.
Returns lens that points to a path in the store. Sub is handled by a rule.
(then facts)
Inserts facts into current session
Inserts facts into current session
(transactor)
Takes from action channel and puts to session->store
channel. Parks until done-ch
returns a message indicating:
then
) was inserted into the (global) session
((:session precept.state/state)
)fire-rules
was called on (:session precept.state/state)
Takes from action channel and puts to `session->store` channel. Parks until `done-ch` returns a message indicating: 1. A transaction of facts (via `then`) was inserted into the (global) session (`(:session precept.state/state)`) 2. `fire-rules` was called on `(:session precept.state/state)` 3. changes were read from the session and applied to the store
(update-session-history session)
First history entry is most recent
First history entry is most recent
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close