Fork me on GitHub
#babashka
<
2020-05-07
>
tatut10:05:50

connecting to babashka nrepl with cider is very nice... but autocompleting doesn't seem to work for me and bb prints stacks with: No namespace: babashka.signal found [at line 1, column 7]

tatut10:05:11

babashka v0.0.91

tatut10:05:24

CIDER 0.24.0

borkdude10:05:32

I'll take a look when you can make an issue for this

borkdude10:05:44

Do you use nREPL or inf-clojure?

borkdude10:05:50

oh CIDER right

tatut10:05:51

% bb -e "(require 'babashka.signal)"
clojure.lang.ExceptionInfo: Could not require babashka.signal. [at line 1, column 1]

tatut10:05:26

I don't know what that namespace is, but I can make an issue if I understand why CIDER needs it

borkdude10:05:10

ah I understand.

borkdude10:05:14

let me fix that

borkdude10:05:19

You were just in time, I was really just hitting the release button for something else

borkdude10:05:15

Should be fixed in v0.0.92

tatut10:05:31

wow, that's a great turnaround time for fixes you have šŸ˜„

tatut15:05:54

works as expected with the new version

borkdude10:05:28

Released v0.0.92 with pod support and released the very first pod: https://github.com/borkdude/pod-babashka-hsqldb Pods are new way of leveraging other command line tools as libraries in babashka. Please try it out. I'll write some pod documentation later this week after the first feedback.

šŸ˜ƒ 4
sogaiu12:05:53

looks good here on linux: https://pastebin.com/T7hWKMAW

šŸ‘ 1
borkdude12:05:07

Thanks!

šŸ‘ 1
jeroenvandijk15:05:01

Looks the same on my Mac šŸ™‚

borkdude18:05:21

Babashka pods are an exciting new way to extend babashka dynamically with features provided by other programs. They are introduced in babashka v0.0.92 released today. Babashka pod documentation: https://github.com/borkdude/babashka/blob/master/doc/pods.md

parrot 4
bananadance 5
šŸŽ‰ 6
nate18:05:34

when I was trying out pods, I came across some odd behavior, which I think may just be hsqldb

nate18:05:45

my script:

#!/usr/bin/env bb

(require '[babashka.pods :as pods])
(pods/load-pod "pod-babashka-hsqldb")
(require '[pod.babashka.hsqldb :as sql])

(def db "jdbc:hsqldb:file:test.db;sql.syntax_mys=true")


(println "create")
(time (sql/execute! db ["create table if not exists entries ( id int not null auto_increment, name varchar(20) not null);"]))

(println "update")
(time (sql/execute! db ["insert into entries (name) values ('foo');"]))

(println "select")
(time (sql/execute! db ["select count(*) from entries"]))

šŸ‘ 1
nate18:05:23

result:

create
"Elapsed time: 102.321462 msecs"
update
"Elapsed time: 12.067853 msecs"
select
"Elapsed time: 13.738398 msecs"
[{:C1 33}]

nate18:05:31

but then when I run it again

nate18:05:16

create
"Elapsed time: 9284.601321 msecs"                                                                                                                                                                                                                             update
"Elapsed time: 11.258119 msecs"
select
"Elapsed time: 13.083133 msecs"                                                                                                                                                                                                                               [{:C1 34}]

nate18:05:27

way longer time for the create

nate18:05:41

I think the hsqldb lock is not getting freed or something

borkdude18:05:12

interesting

nate18:05:16

I wrote another version that just used a custom bb compiled with next.jdbc and hsqldb and it never exhibits the slowdown

nate18:05:25

I can share the other version if helpful

borkdude18:05:01

well, maybe the pod should receive a signal to close itself instead if being killed very harshly

nate18:05:07

ah, I just got a big exception, Database lock acquisition failure

nate18:05:23

yeah, looks like some sort of shutdown would be nice

borkdude18:05:32

although that still doesn't explain why this happens.

borkdude18:05:59

because after the function call, the connection is released you would think

nate18:05:49

I noticed that if I spun up a bb nrepl to execute my code, that it held a lock until I exited the process

borkdude18:05:37

hmm, when I use mem it has the same problem

nate18:05:08

oh, really? that'd odd, I thought it would have to do with the filesystem

nate18:05:30

can you access mem hsqldb databases from different processes?

borkdude18:05:02

oh wait, it created a mem db on disk, I think my jdbc url was wrong

borkdude19:05:16

Can you post an issue in the pod repo?

nate19:05:23

sure thing

borkdude19:05:55

yeah, the in memory version doesn't have this problem

borkdude19:05:15

I'll just implement another op, which shuts down the pod

nate19:05:28

if I add ;shutdown=true to my URL, the lock gets closed

nate19:05:37

(added this as a comment to the issue too)

nate19:05:56

it makes every database access a little slower, but it does fix the lock problem

borkdude19:05:08

good workaround for now.

nate19:05:45

oh, and in the "why didn't I think of this the first time" department, I added this at the end of my script and it made the sql go fast and the lock get cleaned up:

(sql/execute! db ["shutdown"])

borkdude21:05:51

@U0510902N I uploaded new binaries for the hsqldb pod which implement a shutdown op. The next bb will send this op and waits for the pod to exit. I've tested this locally and it worked

borkdude21:05:31

the new bb binaries are also in #babashka_circleci_builds

borkdude21:05:10

so in theory this could all be tested right now

nate21:05:17

cool, will check it out

borkdude22:05:33

just made another change to both bb and the hsqldb binaries. I made a breaking change by introducing the new shutdown op, but now it's optional. So no breaky

nate22:05:38

hm, I just tried to download the pod binary and I got a forbidden error

borkdude22:05:12

hmm it seems that Github is having issues

borkdude22:05:49

I'm getting a lot of 403s on CircleCI from Github as well

borkdude22:05:57

could not download leiningen bash script in CI

nate22:05:28

ok, so github issue

borkdude22:05:33

I'm calling it a night. Check back tomorrow.

nate22:05:44

ok, thanks for pushing on this

nate22:05:53

I can just build each binary myself to try it out, right?

nate22:05:58

(bb and the pod?)

nate22:05:42

I'll try that, thanks

nate22:05:48

have a restful night

borkdude22:05:04

thanks šŸ™‚

uochan21:05:36

I just wrote a pod for toyokumo/tarayo, SMTP client library for Clojure (VERY EARLY) ! native-image is a to-do:disappointed_relieved: https://github.com/liquidz/pod-uochan-tarayo https://github.com/toyokumo/tarayo

šŸŽ‰ 2
jeroenvandijk21:05:16

Thank you for the update to npm Sci @borkdude. Now I can do fun stuff like this in hiccup šŸ˜Ž

[:a {"onClick" "(function(){sci.evalString('(fn [e] (js/alert \"hello\"))',{classes:{allow:\"all\",\"js\":window}})(this);return false})();return false"} "click me"]

šŸ˜Ž 2
jeroenvandijk21:05:09

Iā€™m trying to translate the cljs version [:a {:on-click (fn [e] (js/alert "hello"))} "click me"]