oakes / odoyle-rules

A rules engine for Clojure(Script)
The Unlicense
530 stars 20 forks source link

O'Doyle Rules Cookbook. #18

Open thomascothran opened 2 years ago

thomascothran commented 2 years ago

17

thomascothran commented 2 years ago

I have a few more patterns to add. Happy to adjust for feedback on format (and even happier to be alerted to undesirable patterns I shouldn't be recommending!).

thomascothran commented 2 years ago

There are a couple problems I don't yet have a good solution for, but that could be interesting.

A big one is debuggability. It would be nice to know when the rules are updating.

My current workaround is to wrap o/insert and log or capture values. There may be a better way though.

thomascothran commented 2 years ago

The most recent commit makes the doc more clear on how the joins work in using O'Doyle as a query engine

oakes commented 2 years ago

Thanks i'll look them over when i have time. Just returned from my work trip so still catching up on things.

thomascothran commented 1 year ago

One thing it may be good to add a pattern for is visibility into rules firing. Clara has tracing listener functionality.

With O'Doyle, I've done one of two things:

  1. Every then block must call a function, and those functions are instrumented (with something like debux), or
  2. Wrap the insert function to add logging around when it's called, and what it's called with.

Perhaps there are better ways to do this. But in my experience so far introducing people to O'Doyle, the most common difficulty (other than the paradigm shift) is understanding when and why rules are firing.

oakes commented 1 year ago

Good points. I made a ticket for improving debugging here https://github.com/oakes/odoyle-rules/issues/19

oakes commented 1 year ago

Check out the wrap-rule fn i put in that ticket. I think it's simpler than having to rewrite your rules so they call a single function and instrumenting those functions with some extra library. If you think it's useful, maybe i could add it to odoyle. That will at least tell you when rules are firing, but not necessarily why. I'll add some ideas to that ticket once i think about it more...