Fork me on GitHub
#babashka
<
2020-07-09
>
bhurlow13:07:04

anyone tried compiling the datomic client jar into babashka? not sure if its compatable or that's allowed, but would be great to be able to run one-off queries

jeroenvandijk13:07:17

if itโ€™s datomic-pro it likely wouldnโ€™t work because of at least the aws dependency (although maybe that would not be used). In general i would be surprised if it works. Your best bet is to use a datomic rest client

borkdude13:07:26

Datomic has an HTTP API as well right?

jeroenvandijk13:07:24

Depends on the deployment, possibly

bhurlow14:07:01

my hope was the client specifically would have more minimal deps as it's mostly an HTTP / core.async wrapper, Deps are here: https://search.maven.org/artifact/com.datomic/client/0.8.103/jar

bhurlow14:07:22

Datomic does have an HTTP api, but using the client is preferred for a few reasons

bhurlow14:07:36

Datomic REST API is officially deprecated, also lacks some key things like response chunking, timeouts etc, transit serialization etc

helios07:07:06

seems like a very cool idea ๐Ÿ™‚ hopefully somebody from cognitect sees this

bhurlow19:07:46

Took some initial experiments here found a couple of things:

bhurlow19:07:30

โ€ข datomic client dynamically loads classes depending use, had to directly require the dependents โ€ข datomic client also uses an .pem certificate included as a resources in one of the deps, I had to add a resources regex allow in the native-image script to import that โ€ข also had to add a few classes to the reflection list โ€ข am currently stuck at the following

bhurlow19:07:32

clojure.lang.ExceptionInfo: Class java.nio.HeapByteBuffer[] is instantiated reflectively but was never registered. Register the class by using org.graalvm.nativeimage.hosted.RuntimeReflection

bhurlow19:07:51

@ have you had to register any classes via org.graalvm.nativeimage.hosted.RuntimeReflection in babashka yet?

bhurlow19:07:09

feels like I'm close :crossed_fingers: ๐Ÿ™‚

borkdude19:07:12

No, I don't know what this means ๐Ÿ™‚

bhurlow19:07:17

haha me neither

borkdude19:07:39

You can try asking in the GraalVM slack

borkdude19:07:46

where the GraalVM devs hang out

bhurlow19:07:58

๐Ÿ˜ฑ

bhurlow19:07:24

k I'll drop a line there

borkdude19:07:35

Have you tried adding it to the reflection.json though?

bhurlow19:07:21

yes, interestingly that worked for all the other classes used with reflection, somehow java.nio.HeapByteBuffer seems to be treated differently

borkdude19:07:44

you need to add the array class it seems, note the []

bhurlow19:07:46

so it would seem. What's the syntax for referencing an array class like that from clojure? was adding here https://github.com/borkdude/babashka/blob/master/src/babashka/impl/classes.clj#L136-L147

bhurlow19:07:24

ok trying that now

bhurlow19:07:22

๐Ÿ˜ ayyyyy

bhurlow19:07:25

time ./bb --file client-test.clj
{:user/firstname "Brian (Bingo)", :user/lastname "Hurlow"}
        0.11 real         0.04 user         0.03 sys

bhurlow19:07:45

that was the final reflection required

borkdude19:07:54

cool ๐Ÿ™‚

mikael19:07:02

Cool, seconded!

bhurlow22:07:25

@ put the above in a PR for your perusal, letโ€™s discuss there if you have any thoughts. https://github.com/borkdude/babashka/pull/505

borkdude07:07:03

Thanks! I left a few comments