Fork me on GitHub

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.


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
    [?e :bot.discord/thread-id ?thread-id]]
 (map first)

;; and I wonder if I should do this
  '[:find ?id ?user-id
    [?e :bot.discord/thread-id ?id]
    [?e :bot/thread-user ?user]
    [?user :bot.discord/user-id ?user-id]
    ;;  ... more
  (fn [[id user-id]]
    {:bot.discord/thread-id id
     {:bot.discord/user-id user-id}})))


The inconvenient part is building the map in the second part of the second example


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


aside from that I found the :keys second arg to q


you should probably be doing something like this


(->> (d/q  ; or qseq
      '[:find (pull ?e pull-expr)
        :in $ pull-expr
        :where [?e :bot.discord/thread-id ?thread-id]]
     (map peek))

👀 1

evaluate the pull in the query, possibly parameterize the pull


ah sweet I didn't know yet I can use pull in find


qseq returns a lazy seq right that's the difference?


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


qseq evaluates the result set eagerly, but does the pull only as it’s consumed


it reduces latency to time-to-first-result, and can avoid doing IO for results you don’t consume


cool thanks


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.


In this scenario your sql-url will not change so you are still running a transactor against that storage, but the transactor will have new host/alt host values