xtdb

eighttrigrams 2024-12-19T15:53:51.733539Z

Hello, I wanted to start experimenting with xtdb 2 and a simple in memory node. I get a ; Execution error (BindException) at (Net.java:-2). Address already in use but I can't find documentation which talks about ports (I tried my luck with {:port 3440} but that didn't work).

eighttrigrams 2024-12-19T15:54:12.599849Z

my deps.edn:

{:deps {com.taoensso/telemere             {:mvn/version "1.0.0-SNAPSHOT"}
        com.github.seancorfield/next.jdbc {:mvn/version "1.3.955"}
        com.github.seancorfield/honeysql  {:mvn/version "2.6.1147"}
        org.postgresql/postgresql         {:mvn/version "42.2.10"}
        com.xtdb/xtdb-jdbc                {:mvn/version "2.0.0-beta4"}
        com.xtdb/xtdb-core                {:mvn/version "2.0.0-beta2"}
        com.xtdb/xtdb-api                 {:mvn/version "2.0.0-beta2"}}
 :aliases {:xtdb {:jvm-opts ["--add-opens=java.base/java.nio=ALL-UNNAMED"
                             "-Dio.netty.tryReflectionSetAccessible=true"]}}}

eighttrigrams 2024-12-19T15:54:41.763399Z

and code

(comment
  (require '[xtdb.node :as xtn]
           '[xtdb.api :as xt])

(with-open [node (xtn/start-node)]
  (xt/status node)))

refset 2024-12-19T15:56:57.976629Z

hey @dan203 it's either the default HTTP server on port 3000 or the default pgwire port on 5432 that will be causing the issue - do you happen to already have postgres running?

eighttrigrams 2024-12-19T16:00:29.412789Z

awesome @taylor.jeremydavid, yes, i needed to shut down a docker which still ran in the backround which ran a psql at 5432

🙏 1
eighttrigrams 2024-12-19T16:00:32.767279Z

thank you

refset 2024-12-19T16:28:35.846959Z

on the off chance you're interested, I just put together this examples repo which you can boot up pretty quick with codespaces + calva https://github.com/xtdb/driver-examples/blob/main/clojure/dev/user.clj

eighttrigrams 2024-12-19T16:47:20.060779Z

that's cool. as a clojure user, i tried to go the route in-memory node + xtql

eighttrigrams 2024-12-19T16:47:34.778529Z

so my minimal example was

(defn start-in-memory-node 
  "needs ports 3000 and 5432" 
  []
  (xtn/start-node))

(defn add-person [node name email]
  (xt/execute-tx node [[:put-docs :persons {:xt/id        name        , 
                                            :person/email email}]]))

(defn list-persons [node]
  (xt/q node '(from :persons [xt/id person/email])))

eighttrigrams 2024-12-19T16:47:45.491639Z

(deftest add-and-retrieve-persons
  (testing "add and retrieve a person"
    (is 
     (= {:xt/id        :dan
         :person/email "d@et.n"}
        (first (with-open [node (ds/start-in-memory-node)]
                 (ds/add-person node :dan "d@et.n")
                 (ds/list-persons node)))))))

eighttrigrams 2024-12-19T16:48:27.920649Z

(doesn't have to be from a test could be done from a comment) just demo-ing what i personally found the most gratifying and cognitively easy example to start from

refset 2024-12-19T16:51:34.048039Z

cool, glad to hear 👌

🙏 1