sixthnormal / clj-3df

Clojure(Script) client for Declarative Dataflow.
Eclipse Public License 2.0
328 stars 13 forks source link

Business rules #29

Closed li1 closed 5 years ago

li1 commented 5 years ago

This adds support for business rules.

To enable that, the basic connection structure has been changed to provide a tap in into the ws to log debug messages and a pub/sub system for everything else. Perhaps this can be made even simpler?

bachdavi commented 5 years ago

I'm not sure if we need the expect anymore. We are porting the test suit to the backend and keep the compiler tests in the frontend. The tests in test/core.cljc are broken right now... I mean would still be nice to have I guess, but if it is too much trouble...

comnik commented 5 years ago

I like the idea behind sub-type, but I don't like the parameterisation approach. Separating connection and subscriber is great (maybe subscriber is the wrong word, let's call it middleware or sth). Apart from that there are some inconsistencies (create-debug-subscriber is missing, and the parameter check is only being done in cljs I think?).

How about for now we change the sub-type parameter in create-subscriber (-> create-middleware) to be a function that gets whatever the channel would get. In principle there should be a nice way of hooking into the channels themselves, but why bother.

Then have create-conn accept an optional middleware. W/o a middleware, we give the output channel directly to the Connection instance (saving the extra thread). If a middleware is passed, we do what you're doing right now.

Finally we provide specialisations on top of that. The first one would just be (create-conn ...) which sets up a connection with no middleware and without wrapping into a publication. The second one would be (create-debug-conn ...) which is simply a convenience method for a connection with a println middleware. And finally a (create-publication) w/o middleware but wraps a publication.

For any specialisation it should be possible to do e.g. (create-publication (fn [result] (call-mom! result))) to add arbitrary middleware.


It's true that exec! is mostly for testing and demos, but let's leave it for now.

li1 commented 5 years ago

I updated the tests.

There are still three issues (which I assume aren't directly related to this PR):

  1. min and max tests fail, they print out both tuples, not only the smallest one
  2. While executing the tests by hand (e.g. eval-last-sexp the let-sexp of each test) does work, running them using the test runner panics 3DF
  3. Related to 2, running multiple tests back to back by evaluating the let-sexp only works when 3DF is restarted between each run, otherwise 3DF panics with `attribute "..." does not exist (I guess statefulness and all that...)
comnik commented 5 years ago

Yeah (2) and (3) sound familiar, but (1) is a regression. Could you file an issue for that?