Fork me on GitHub

@apsey, that's very interesting. > a way to get the transactor host from the connection I don't know if this is part of the public API > encode and decode data that is being transacted or queried I'm not sure what this would get for you?


Datomic has a new HTTP endpoint you can query to get some status info, but I'm not sure if that's what you need here


Datomic has a lot of the HA stuff built-in, as well as connection retries I think


But it's all internal, I'm not sure how well it's exposed to the user


Is it possible to just monitor the queries and transactions, and fail if they fail, but in the background retry to try and let Finagle handle the self-healing and backoff?


hey y’all, what are the best practices around creating datomic connections? I’m using datomic for a web app, and is it ok to call d/connect once per API request?


> Datomic connections do not adhere to an acquire/use/release pattern. They are thread-safe and long lived. Connections are cached such that calling datomic.api/connect multiple times with the same database value will return the same connection object.


from d/connect docstring


however as a matter of code architecture, I would suggest maybe using the Component architecture that does use a long-lived connection


It makes reloading easy, and helps you easily use a memory database for testing


You can do it either way, but if you need to inject a URI to connect to, then you may as well inject a full Datomic Component


@U0AQ1R7FG not relying on URIs also gives you the opportunity to do things like forking etc.


Here's a fully worked component that might be useful as a starting point:

(ns app.system.datomic
  (:require [com.stuartsierra.component :as component]
            [datomic.api :as d]
            [app.datomic.schema :as schema]
            [clojure.spec :as s]
            [clojure.string :as str]
            [suspendable.core :as suspendable]
            [ :as log])
  (:import (datomic Connection)))

(s/def :datomic/conn (partial instance? Connection))
(s/def :datomic/uri (s/and string?
                           #(str/starts-with? % "datomic:")))

(defrecord Datomic [uri conn]
  (start [component]
    (let [created? (d/create-database uri)
          conn (d/connect uri)]
      (when created?
        (log/info "Creating a new datomic database:" uri))
      (schema/ensure-schema conn)
      (assoc component :conn conn)))
  (stop [component]
    (when conn (d/release conn))
    (assoc component :conn nil))
  (suspend [component]
  (resume [component old-component]
    (if (and (= (dissoc component :conn) (dissoc old-component :conn))
             (some? (:conn old-component))
             ;; Try and sync the db, to ensure that we are still connected
             ;; If not, we shut down the component and try to reconnect.
               (deref (d/sync (:conn old-component)) 500 false)
               (catch Exception e
      (assoc component :conn (:conn old-component))
      (do (component/stop old-component)
          (component/start component)))))

(defn new-datomic [{:keys [uri] :as config}]
  (map->Datomic {:uri uri}))

(s/fdef new-datomic
        :args (s/cat :config (s/keys :req-un [:datomic/uri])))
YMMV ofc


Hello! Question regarding txReportQueue. So if I subscribe from a Peer to txReportQueue at Time=t0 where maxTxId=XXX and keep getting messages until Time=t1 where maxTxId=YYY, if for some reason connection to datomic breaks from t1 to Time=t3 where maxTxId=ZZZ, when my Peer recovers will it get all the txIds YYY-ZZZ or it will start getting after ZZZ?


No, txReportQueue is a realtime notification system, use the Log API for catching up


Hey all. Noob question. Is it possible to start datomic in local (in memory) mode, and then migrate to a backing store, without losing all the in memory datoms?

chrjs15:07:59 seems to suggest swapping out the backing store is possible.


In memory databases can't be backed up, so they can't be restored


You need to replay the tx-log of the mem db and manually copy


Ah, ok. Thought that might be the case. Thanks!


@danielcompton can you guide me to the new HTTP endpoint status info API? I am still researching, but I dont think it is possible to activate finagle only in the failing cases, if that is what you are suggesting


that’s probably worth studying - thx @robert-stuttaford


Can I call functions from my application’s namespace / librairies in a Datalog queries? I tried but got an error. I suspected it’s because the quoted query could not reference the functions I was using, so I tried syntax quoting (which auto-prefixes every symbol), but then the variables (e.g. ?trete) got prefixed too and everything broke


I would like to use some functions from the clj-time package in my query


Ah, I found the relevant passage of the doc


> Function names outside clojure.core need to be fully qualified, and their namespaces must be loaded before use in query.


I tried that and still got an error, but will try again


nevermind, full qualification does fix it. I must have made a mistake earlier


are you doing it using the client library?


peer library


Can datomic-console-0.1.214 be installed and run with datomic-free-0.9.5561.50 ?


could be I blew the installation, but for me it's crashing at startup with

console_1     | Exception in thread "main" java.lang.IncompatibleClassChangeError: Implementing class
console_1     | 	at java.lang.ClassLoader.defineClass1(Native Method)
console_1     | 	at java.lang.ClassLoader.defineClass(
console_1     | 	at


same issue with datomic-free-0.9.5561.54 and each version back to 0.9.5544


ah, nevermind. I found this comment in the Google group!topic/datomic/TiRcDBqs9cM