Fork me on GitHub
#sql
<
2018-03-14
>
seancorfield17:03:10

@souenzzo Yeah, I read that this morning on my phone and it doesn't tell you much -- nor could I find much in the way of documentation (beyond the source itself!). Now I'm on my desktop, I see there's a slide deck so I'll watch that. Might be interesting to implement something like it directly in Clojure, rather than wait for Java 10.

seancorfield17:03:13

Looking at it in more depth, it's not really much more than

(let [p (promise)]
  (future (deliver p (whatever jdbc stuff)))
  p)
and just knowing everything is derefable instead of direct values. And you have to deal with the ugly builder syntax for everything.

donaldball19:03:30

It claims not to block threads though, I mean, that’s pretty great for certain workloads

seancorfield20:03:28

Most of the examples are fire-and-forget inserts, but the selects produce CompletableFuture so code somewhere has to deref that so will block (as I understand futures?).

ikitommi03:03:06

You can register callbacks to CompletableFuture when the operation is done, so no need to do manually deref, “Uses nio Selector so non-blocking all the way sown”, so no application threads should be waiting for the result - if you app supports async.

seancorfield05:03:16

True. Wish we had that in Clojure. It's been on the planning board for several releases.

donaldball20:03:55

Sure, but you can do useful other work before you need those results. You can also fire off a bunch of queries at the same time without parking a thread for each one.

seancorfield20:03:44

Aye, for certain workloads I can see that being useful.

seancorfield20:03:34

I guess the closest way to implement all that in Clojure -- other than as a wrapper around that new Java 10 library -- would be via core.async...

val_waeselynck23:03:43

@U04V70XH6 Not sure if that's what you meant, but core.async can't help you get the performance benefits of the Java 10 library. It can only help you make it less complex to consume a non-blocking API, but it can't make the API non-blocking. I wrote a bit about this here: https://stackoverflow.com/questions/24980014/can-i-make-a-fully-non-blocking-backend-application-with-http-kit-and-core-async

seancorfield23:03:16

Right, I only meant in terms of parking, rather than just using threads for "everything".

seancorfield23:03:59

Great article on SO!

ikitommi03:03:06

You can register callbacks to CompletableFuture when the operation is done, so no need to do manually deref, “Uses nio Selector so non-blocking all the way sown”, so no application threads should be waiting for the result - if you app supports async.