Fork me on GitHub
#datomic
<
2023-04-26
>
Eduardo Lopes12:04:13

I'm trying to implement a lib for enhancing my personal workflow with datomic projects, is there a good way to execute datomic from a clojure code? For both start methods that I know I managed this way: • For using datomic pro zip I can manage using a local env var like DATOMIC_DIR and on repl start execute (sh "bin/transactor" ...) and even bin/console. • For using cognitec dev tools I had to runhttps://docs.datomic.com/cloud/dev-local.html on my downloaded zip and then connecting the client Both ways I had to manually install some zip and do something more than lein deps or just executing my REPL. I can think of manually wget with sh , or even add to git versioning but I was thinking if could be a better solution, some magic .jar that can be run or even a lib to add on app.edn. The goal is to just execute my REPL and with one function I could start datomic, console, localstack, etc, and I already got it. But it would be awesome avoid downloading/installing any zip or file, to local development setup be just a REPL start.

souenzzo13:04:51

clj -Sdeps '{:deps {com.datomic/datomic-free,{:mvn/version"0.9.5697"}}}' -M -e "(require,'[datomic.api,:as,d])" --repl
WARNING: requiring-resolve already refers to: #'clojure.core/requiring-resolve in namespace: datomic.common, being replaced by: #'datomic.common/requiring-resolve
user=> (d/q '[:find ?e :where [_ :k ?e]] [[0 :k 42]])
#{[42]}

2
souenzzo13:04:58

unfortunately datomic team do not update datomic-free anymore so to use updated datomic, we need to do like a cave-man, click on links, receive emails, download zips, etc

🙁 2
Eduardo Lopes17:04:22

Thats actually awesome, but is a version from 2012 😢

Eduardo Lopes17:04:00

Something updated like this in maven would work perfectly for what I am thinking

souenzzo17:04:43

Look again man

Eduardo Lopes17:04:13

I looked here, not really familiar with this maven website

souenzzo08:04:06

my bad. now you can use:

clj -Sdeps '{:deps {com.datomic/peer,{:mvn/version"1.0.6726"}}}' -M -e "(require,'[datomic.api,:as,d])" --repl
user=> (d/q '[:find ?e :where [_ :k ?e]] [[0 :k 42]])
#{[42]}
the correct link is: https://central.sonatype.com/artifact/com.datomic/peer/1.0.6726

Eduardo Lopes15:04:55

But for using peer we need a transactor running, right? I was trying to create a database and it fails (d/create-database "datomic:dev:/ /localhost:4400/teste?password=123") , my intention is to run datomic without switching for other terminal and run bin/transactor

souenzzo15:04:19

No. Just use (def conn (-> "datomic:<mem://hello|mem://hello>" (doto d/create-database) d/connect))

Eduardo Lopes15:04:01

I'll try that, it works only for memory datomic? Or datomic:dev too?

souenzzo15:04:56

I don't see any reason to work with datomic:dev locally. I only use datomic:dev when I was restoring a prod database locally to do some analysis The best part o datomic is that you can create memory databases and run integration tests as if it is an unit test, without mocking

Eduardo Lopes15:04:46

I am exactly on a current work that I restore a lot prod database to run the processes with real data, the data Is really complex to manually add to datomic and Is a legacy system without good seeders. 🥲

souenzzo15:04:01

There is docs about run a local transactor. It should be ok to run. But you need a license key in the config file.

Eduardo Lopes15:04:53

Yes, thats actually achievable by downloading a datomic-pro and add the path to a var like DATOMIC_DIR, then run (sh "bin/transactor...". My point was to avoid this manual download and export manually a var. Then without this manually overheads I could add to a lib that would simplify my workflow on REPL. I was reading bin/transactor and the command to start is exec java -server -cp bin/classpath` $XMX $XMS $JAVA_OPTS clojure.main --main datomic.launcher "$@"` what made me think if I could run (datomic.launcher) from a clojure file instead of using bash for it. But it seems easier create a dockerfile that runs a wget and start bin/transactor.