Fork me on GitHub
#xtdb
<
2021-04-14
>
richiardiandrea22:04:44

Hi again, long time no speak 😄 Thank you for the blog post about (bi)temporality being very important nowadays...I think I really see this in my current (new) workplace (healthcare). One of the things we have as a requirement is a list of every "business events" that happened to an entity/record. Event sourcing is the obvious choice we have but I was trying to understand how I would satisfy that use case with crux instead...

richiardiandrea22:04:32

One idea I remember maybe have seen here was to have a custom transaction function enabled on some entity that "tags" the update with the, say, event type...

refset23:04:34

Hey, congrats on the new role! 🙂 There's quite a few ways to apply Crux to an event sourcing design but I'm not sure there's an obvious "best" option. It certainly depends a lot on the scale of the system, like: • how many projections you expect to model in the same Crux instance, and • the average/maximum expected length of the event sequence • whether you need "point-in-time" temporal queries, easy access to old projection states, or can live with rebuilding inactive projections on demand

❤️ 5
💯 2
refset23:04:54

Have you started experimenting in any particular direction?

richiardiandrea23:04:01

not yet but to reduce the scope I was thinking of POC-ing exposing the "business centric" logs of a record

richiardiandrea23:04:52

it does not have to be "reactive" - I would just query it ad-hoc but it would be nice to have something that gives me both attributes and the events from a certain date...I am certain this is doable in crux but I have to find the most elegant solution in order to motivate the move 😄

richiardiandrea23:04:53

maybe a field on the entity call :log would work actually

👍 3
richiardiandrea23:04:07

if instead I wanted to go for tagging transactions then I could instead probably show off the queries with valid-time - which would definitely make crux shine

🙂 3
ordnungswidrig06:04:33

Did you consider attaching the business event to the affected entities as a referenced entities? I.e. storing the business event and updating the events with a reference to the former? FatimidDatomic supports metadata on transactions, no sure about crux.

refset17:04:41

I'm guessing Fatimid was an autocorrect for Datomic 😄 there's no reified transaction log in Crux, but you can maintain your own metadata log entity that references the changed entities, and in general use the entity-history API to efficiently correlate histories when needed

richiardiandrea17:04:22

Uhm ok thanks to both I will have to try that

richiardiandrea18:04:57

The only thing there then is that I still don't see from what I have read about the blog post is how crux would be a (simpler) alternative to event sourcing...again I might have been missing some nuance that POC-ing will unveil 🙂

ordnungswidrig07:04:28

@U899JBRPF oh the perils of mobile phone typing. I’ve corrected the sentence.

ordnungswidrig07:04:46

@U0C8489U6 there would also be the option to store the event stream to crux and also store the reified data as processed from the even stream into crux as the read model. separately. This can be even done with tx-functions I suppose.