Fork me on GitHub
#clara
<
2019-10-06
>
jjttjj15:10:45

Are clara sessions intended as throwaway cheap things meant to replace an elaborate cond? I have a long running process that receives events every few seconds, and needs to make decisions based mainly on that new data point, and to a lesser extent some previous, accumulating state, but not previous events in the stream. Which one is the default approach with clara: a new session for each new data point, adding in the needed extra state with insert? Or should I be building up one session over time and retracting the old/unused data points

jjttjj15:10:06

Put slightly differently, the "sensors" example in the clara-examples repo seems similar to what i'm trying to do, but I'm not quite sure how the main function would translate to the "real world": https://github.com/cerner/clara-examples/blob/master/src/main/clojure/clara/examples/sensors.clj#L87 Should the same session persist throughout the long-running process that provides the sensor data? Or is the run-examples function similar to something that would be called frequently in response to new data?

mikerod16:10:52

@jjttjj you could certainly create one “base session” and hold a reference to it

mikerod16:10:12

Then do insert+fire on independent “branches” from there. In isolation

mikerod16:10:46

If old state doesn’t need to influence “new” you don’t need to try retracting the last cycle of facts etc. just start from scratch again from the base session

mikerod16:10:54

This will be cheap.

jjttjj16:10:30

great, thanks!

👍 4