holy-lambda

carlos hernandez 2021-12-16T22:50:01.161400Z

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 hernandez 2022-01-05T21:54:52.175100Z

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

carlos hernandez 2021-12-16T22:51:59.161500Z

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

emccue 2021-12-16T22:54:58.161700Z

does d/connect make a non-daemon thread?

emccue 2021-12-16T22:55:27.161900Z

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

(def conn (d/connect))

emccue 2021-12-16T22:55:37.162100Z

because my first guess is that you are making AOT hang

carlos hernandez 2021-12-16T22:59:42.162300Z

Yes I'm calling it like you say

carlos hernandez 2021-12-16T23:00:04.162500Z

How should it be done?

carlos hernandez 2021-12-16T23:02:11.162700Z

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

emccue 2021-12-16T23:04:38.163Z

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

emccue 2021-12-16T23:04:44.163200Z

i would call it like this

emccue 2021-12-16T23:06:24.163400Z

(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
emccue 2021-12-16T23:06:48.163600Z

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

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

emccue 2021-12-16T23:07:55.163900Z

and then replace your usages of conn with @conn

carlos hernandez 2021-12-16T23:09:01.164100Z

Works just as you say, thanks for your help!

Karol Wójcik 2021-12-17T06:59:42.167500Z

@emccue @carloshernandez2.1b very good explanation. Will NuBank use holy-lambda in production?

Karol Wójcik 2021-12-17T07:05:27.172300Z

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.