Open VictorVSa opened 4 months ago
A contribution for Datomic would be very much welcome, it might be worth taking a look at making it a module instead of a profile. I generally prefer adding functionality via modules since they can be instantiated after project creation meaning you don't need to know what functionality you'll need up front when making the initial project.
The modules repo is located here https://github.com/kit-clj/modules
I would love to have an easy way to hook in Datomic, especially as a module.
@yogthos @gerdint I have 2 approaches for Datomic support, please check the diffs and let me know which one follows the philosophy best, then I'll open the MR in the modules repo:
With transactor process management: Datomic can be deployed in many ways, so most of it should be done outside the lifecycle of the system in Kit, but it is a bit annoying having to manually start the transactor for development (that uses file DB) every time. This branch includes starting a dev transactor with defaults taken from the Getting started section of Datomic Pro. The user could just provide a DATOMIC_PATH env variable after following the instructions there and it works.
It includes a Thread/sleep because usually you can't connect to the transactor right after spawning the process, it will fail and retry, but it can be, because it happened to me, that the retry timeout is too short and you never end up connecting to the transactor, being left with a very polluted repl full of errors. The transactor has a healthcheck endpoint, but for that you have to edit the config file, which is an extra step for the user and not very beginner friendly, probably.
Without transactor: Much simpler, it only cares about the DB URI to know where to connect and that's it.
Thanks!
I wonder if a bb task might be a better place for starting the transactor since it's not actually part of the app and it's only used for dev.
That might need creating a scripts
folder and call the scripts from the bb.edn
like how rewrite-clj does it maybe? The approach without transactor can be the start, and if you like the idea of having a scripts folder that can be extended by the user at will, then I can create a script for the transactor, + support for datomic migrations
Well, I'm assuming including that as a base feature of kit-clj, it could also be a documentation tutorial on how to add such a script instead
Adding scripts folder by default might be the way to go, there's already build.clj
script. So that could be moved into scripts
, and then other scripts can be populated there as well via modules. That should be a relatively small change for the base template.
So, let's go with the version without the transactor then, and we can make a follow up issue to update the template and then add a script for starting the transactor for the module.
I recently integrated a Datomic database (both dev/file version and with PostgreSQL) in a kit project, and I found it extremely interesting and exciting. I was wondering if it would be interesting to have a profile that adds the necessary bits for having Datomic ready to use, including a migration tool, I used https://github.com/gethop-dev/stork for example. I can try to make the profile and contribute!