Fork me on GitHub
#clr
<
2023-05-25
>
dangercoder20:05:38

https://github.com/Dangercoder/clojure-clr-dotnet-api just received some updates. • database access (postgres) using https://www.npgsql.org/index.html. There's a few functions for creating a database connection pool, connection, execute sql statements sync and async. The query results are transformed to edn with the right types. • the http machinery now uses clojure.data.json • core.async Unexpected numbers: Did some testing against my own postgres database and the synchronous clojure-clr database access was 5-8 times faster at all times compared to next.jdbc .NET 7 Clojure-CLR database access - Elapsed time: 2.2049 msecs

(time (->> (with-open [conn (a/<!! (->connection datasource))]
          (execute!! conn ["SELECT * from mydatabase.user"]))))
JDK 11 Clojure database access (next.jdbc) - Elapsed time: 11.108928 msecs
(time 
   (next.jdbc/execute! db ["SELECT * from mydatabase.user"]))

👏 8
🔥 6
dangercoder20:05:56

A heads up https://github.com/Dangercoder/clojure-clr-dotnet-api/blob/master/clj_api/interop/dotnet/http.cljr#LL67C24-L67C24 We can currently not go non-blocking when using .NET for api's since go-blocks doesn't suspend tasks from continuing their execution, and a/<!! is blocking. clojure-clr needs async await support or some better way of interoping with Task's.

👍 2