Fork me on GitHub
#holy-lambda
<
2021-12-16
>
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 😅

emccue22:12:58

does d/connect make a non-daemon thread?

emccue22:12:27

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

(def conn (d/connect))

emccue22:12:37

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?

emccue23:12:38

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

emccue23:12:44

i would call it like this

emccue23:12:24

(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
emccue23:12:48

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

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

emccue23:12:55

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 tools.build in the next release.

carlos hernandez21:01:52

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