Fork me on GitHub
carlos hernandez22:12:01

Hi everyone! I'm Carlos, a backend engineer at Nubank who loves Clojure 😄 I've been trying holy-lambda for last few days and I really like it! I'm just running with an issue when trying to compile using bb hl:compile . It happens when I call the d/connect function (or any other datomic.api function) in my project. If I remove it the problem disappears... Do you have any clue why this might be happening?

carlos hernandez22:12:59

It's important to say that the issue is that the terminal blocks 😅


does d/connect make a non-daemon thread?


and are you calling it at the top level of your code like

(def conn (d/connect))


because my first guess is that you are making AOT hang

carlos hernandez22:12:42

Yes I'm calling it like you say

carlos hernandez23:12:04

How should it be done?

carlos hernandez23:12:11

Do you know where can I find some docs about it?


so this isn’t about holy lambda so much as its about AOT in general


i would call it like this


(defn connect-to-datomic 
  (d/connect opts))

(defn start-system
  {:datomic (connect-to-datomic)})

;; then in your entrypoint
(... (let [system (start-system!)]
       (... do code ...)
       // potentially clean up beteen invocations ...)

👀 1

but the “lazy” solution for you to get your stuff working is just

(def conn (delay (d/connect)))


and then replace your usages of conn with @conn

carlos hernandez23:12:01

Works just as you say, thanks for your help!

Karol Wójcik06:12:42

@U3JH98J4R @U02R05V9NLD very good explanation. Will NuBank use holy-lambda in production?

Karol Wójcik07:12:27

Btw hl:compile does nothing special. It's an alias for the command that compiles a project with an AOT, since uberjar happens locally via depstar now. The reason hl:compile exists is to inform hl:native:conf how the project should be compiled for the GraalVM agent. Planning to move to in the next release.

carlos hernandez21:01:52

Hi @UJ1339K2B! Awesome, thanks for sharing. At the moment I'm just exploring.