Fork me on GitHub
#hyperfiddle
<
2024-02-01
>
chromalchemy01:02:15

I appreciate that Electric is db agnostic. But does anyone have any soft guidance about what state persistance would be a recommended natural fit for electric atm. Like if heavier DB’s impose extra considerations or limitation of the reactive nature. I don’t have a strong sense of what my requirements even are. But is it maybe more solid to stick to using atoms until I definitely need something else, .. or is it all the same for electric… fine to just use those, or Datascript, Datalevin, or Datomic, up the (datalog) tree. (specifically thinking about Datascript vs XTDB vs Datalevin… or none of the above? do I need a real db?). I remember some warnings about needing to get the db connections stuff right with missionary, and that ideally the db would be built with electric. Just wondering about current perspectives on the state of electric vs dbs from a starter perspective. Thx

Dustin Getz01:02:35

we will be adding more datomic demos to electric fiddle and are quite happy with datomic onprem. which means it’s more likely that we already have any helpers you may need

👍 2
Garrett Hopper02:02:47

@U09K620SG, I've seen a couple mentions of using Datomic's tx-report-queue to reactively rerun queries, however it seemed to me that it was more of a fun trick that wasn't expected to scale, since every active query would have to rerun on every transaction. Is this the case, or are you using something like this in anger? (This is the first I've heard of your team using Datomic onprem specifically.) I would've assumed this would require filtering new transactions for only those that would apply to each individual query, although perhaps Datomic's cache is efficient enough to do this for a reasonable amount of active queries?

Dustin Getz02:02:45

nobody has come to us yet with this problem in practice, when a serious project presents with a real perf issue we will help work out the patterns. Remember, you can use missionary locally at any point to do things like locally throttle. even in a chat app like slack, most views are not realtime

Dustin Getz02:02:53

and real-time apps have event based data layers anyway not databases

Garrett Hopper02:02:09

👍 All fair points

Garrett Hopper02:02:11

(Probably a case of trying to prematurely optimization on my part)

zeitstein20:02:09

Q re: RCF: I have test running set up as described in https://github.com/hyperfiddle/rcf?tab=readme-ov-file#ci. However, when I run clojure -X:test ... the process/terminal hangs with all tests passing. So, if I e.g. want to run tests as first of multiple scripts, the following scripts don't execute. Any ideas?

Dustin Getz20:02:32

i haven't seen that before, can you send us a minimal repro?

zeitstein20:02:45

Definitely something in my code, I isolated one src dir as problematic.

Dustin Getz20:02:10

are you using async rcf? maybe you hung a test

Dustin Getz20:02:19

all assertions passed but it didn't complete

zeitstein20:02:18

No. I think I have it:

(ns foo
  (:require
   [xtdb.api :as xt]
   [hyperfiddle.rcf :refer [tests]]))

(def node (xt/start-node {}))

(tests
  1 := 1)

;; hangs without this
#_(.close node)

zeitstein21:02:25

A hacky workaround:

;; at end of ns, assuming no other test-generating ns uses `node`
(when (System/getProperty "hyperfiddle.rcf.generate-tests")
  (println "closing node")
  (.close node))

👀 1
zeitstein21:02:33

I don't know enough about these things, but it seems to me this is not an RCF issue.

zeitstein21:02:34

That makes sense.

refset23:02:55

I'm well out of context, but this issue & comment is possibly relevant https://github.com/xtdb/xtdb/issues/1882#issuecomment-1387131584

👀 1
zeitstein13:02:33

This seems to work well both for convenient REPL development (as long as you run the tests manually or through rcf, i.e. clojure.test/run-tests will close the node) and through test runners (exits properly).

(ns test
  (:require
   [xtdb.api :as xt]
   [clojure.test :refer :all]
   [hyperfiddle.rcf :refer [tests]]))

(def node (xt/start-node {}))
(xt/submit-tx node [[::xt/put {:xt/id 1}]])
(xt/sync node)

(use-fixtures :once
  (fn [t]
    (t)
    (.close node)))

(deftest bar
  (is (= (xt/entity (xt/db node) 1)
         {:xt/id 1})))

(tests
  (xt/entity (xt/db node) 1) := {:xt/id 1})

🙏 1