Fork me on GitHub
#missionary
<
2023-10-18
>
denik20:10:31

trying to watch an atom of a hash-map and get granular updates by mapentry. here’s an implementation that processes through all map entries on each change.

leonoel05:10:44

what is the context ? it seems to overlap with what we've been working on for the next electric

leonoel05:10:47

also keep in mind the naive solution should be quite efficient for reasonably low fanout, the entire downstream graph is touched but thanks to work-skipping optimization the previous states are reused

denik17:10:52

this is too automatically refresh oauth tokens

denik17:10:41

which for now are stored during the lifecycle of the application in an atom like {:token {:email .., :refresh-token .., :expiry ..}}

denik17:10:49

so I was looking to use (m/?> ##Inf ) to start m/sleep until expiry at which point the token should be refreshed

leonoel18:10:15

what about a map of atoms ?

denik18:10:59

that can work

denik18:10:36

as a quick interim solution

denik18:10:08

down the road this data will likely go into a datalevin at which point a tx-listener will provide granular updates that can be grouped by the eid

leonoel18:10:57

so the global atom is replaced by the database ?

denik18:10:12

yes in the future

leonoel18:10:21

that makes sense

denik18:10:40

then the db does the diffing

denik18:10:04

however, an example of diffing with missionary would be great. However, happy to use the map of atoms or db approach in the interim

leonoel18:10:28

but in this case you already have the diff information, that seems wasteful to re-diff the full map whenever it changes

leonoel18:10:05

it is the same complexity as having N watchers

leonoel18:10:16

one thing you can do is to use group-by on the flow of writes, in discrete time