Fork me on GitHub
#datomic
<
2018-05-13
>
joshkh14:05:46

i'm pretty new to datomic and not sure if i'm asking the "right" question, but maybe someone can help? i have two apps that use datomic (cloud). one app is responsible for authenticating a user and then linking them to some entity in datomic. the other app kicks off this process, gets back a confirmation that some datoms were updated, and then queries for that linked entity. the first time the query runs i get back nothing, and then all subsequent queries return the linked value. how asynchronous is transacting vs. reading?

joshkh14:05:01

or in other words, how can i guarantee that another peer/client has immediate access to the data after a transaction has occurred?

misha17:05:40

@joshkh have a look at the sync fn discussed literally just before you posted a question

souenzzo18:05:39

@joshkh you can do something like

;; On srv1
(let [tx-data (do-auth-stuff request)
      {:keys [db-after]} @(d/transact conn tx-data)
      basis-t (d/basis-t db-after)]
  (send-to-srv-2 basis-t))

;; On srv2
(let [db @(d/sync conn basis-t)]
  (do-srv2-stuff db ...))
Then, db on srv2 will "wait" to a db with this basis-t. But as @misha said, d/sync without a t will ask the transactor "the newst db at this time"

joshkh18:05:22

cheers, thanks! i'll give it a whirl.

joshkh20:05:41

out of curiosity, is d/sync only available on-prem and not applicable to datomic cloud? i see it here: https://docs.datomic.com/on-prem/clojure/index.html#datomic.api/sync but not here: https://docs.datomic.com/client-api/index.html