This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-03
Channels
- # announcements (8)
- # aws (2)
- # babashka (16)
- # beginners (173)
- # calva (13)
- # cider (4)
- # cljfx (6)
- # cljs-dev (108)
- # clojure (63)
- # clojure-australia (2)
- # clojure-dev (10)
- # clojure-europe (73)
- # clojure-italy (8)
- # clojure-nl (4)
- # clojure-norway (5)
- # clojure-uk (4)
- # clojurescript (49)
- # clojureverse-ops (4)
- # community-development (3)
- # core-async (23)
- # cursive (3)
- # data-science (5)
- # datomic (25)
- # emacs (3)
- # events (1)
- # fulcro (13)
- # helix (5)
- # introduce-yourself (1)
- # lein-figwheel (1)
- # lsp (36)
- # malli (1)
- # meander (2)
- # membrane (4)
- # music (8)
- # nextjournal (51)
- # off-topic (47)
- # other-languages (5)
- # pathom (31)
- # pedestal (5)
- # planck (14)
- # polylith (5)
- # portal (1)
- # re-frame (30)
- # react (2)
- # reagent (24)
- # releases (1)
- # rewrite-clj (18)
- # ring (9)
- # sci (33)
- # shadow-cljs (49)
- # testing (3)
- # tools-build (21)
- # tools-deps (29)
- # vim (19)
- # web-security (1)
- # xtdb (12)
Jo I have a tx (eid) and now I'd like to say as-of
1 before that. Use case is I know a "bad" tx and want to check the db right before I made it.
You can use dec
on it.
https://gist.github.com/souenzzo/eb3753302d5af047346ac1c510500e69
With the client api. Let's say I like pull
syntax and I want to pull a lot of entities, do I still use the q
? Because I'm naively querying eids and then pulling them one by one. It's basically just for the convenience of building a map out of the data
Could you be more specific? Maybe show some code that’s “I do this” vs “should I do this instead”?
;; I do roughly this
(->>
(d/q
'[:find
?e
:where
[?e :bot.discord/thread-id ?thread-id]]
db)
(map first)
(map
(fn
[e]
(d/pull
db
'[:bot.discord/user-id
:bot.discord/thread-id
{:bot/thread-user
[:bot.discord/user-id]}]
e))))
;; and I wonder if I should do this
(->>
(d/q
'[:find ?id ?user-id
:where
[?e :bot.discord/thread-id ?id]
[?e :bot/thread-user ?user]
[?user :bot.discord/user-id ?user-id]
;; ... more
]
(get-db))
(map
(fn [[id user-id]]
{:bot.discord/thread-id id
:bot.discord/user
{:bot.discord/user-id user-id}})))
these are slightly different. The second one will never produce a nil/absent user-id, the first will
yea actually I realized that is also a constraint for my use case. I do want the nil
(->> (d/q ; or qseq
'[:find (pull ?e pull-expr)
:in $ pull-expr
:where [?e :bot.discord/thread-id ?thread-id]]
db
'[:bot.discord/user-id
:bot.discord/thread-id
{:bot/thread-user
[:bot.discord/user-id]}])
(map peek))
using pull in query is more important on client api than on-prem. On the client api, each pull is another (possible) network round-trip
it reduces latency to time-to-first-result, and can avoid doing IO for results you don’t consume
your instinct to parameterize the pull-expr was really nice because I could plug my old code into it, beautiful
What happens if i configure a transactor using a host and alt-host and then i want to move the host / alt host ? For example, i start the transactor, it writes its location to storage, then I use storage and transactor in prod, then someone for whatever reason wants to switch the transactor host. If I start a new transactor with a new host / alt host, will it overwrite its location in storage? If not, how do i get around this ? Would you go into postgres/dynamo/whatever and update the map with the new transactor host ? One such reason might be, you used the public hostname for an EC2 instance and then you needed to restart and you got assigned a new address, or you were using a CNAME and forgot to renew your registration in godaddy and lost the host name.
Jdkealy, host
and alt-host
are written by the transactor to storage. Peers attempt to connect to host and then alt-host. You should be able to launch a new transactor serving the same system with new host/alt-host values (that transactor will be in standby mode) and then kill your old transactor and HA failover will make the standby the active transactor and it will write it's value to storage to allow peers to locate it. Peers will then connect provided they have the proper permissions to connect there. https://docs.datomic.com/on-prem/operation/deployment.html#upgrading-live-system