Fork me on GitHub
Drew Verlee03:11:29

The documentation of the Custom transaction functions lists: • atomic transformation functions in transactions • integrity checks and constraints • spec-based validators • and much more - your imagination is the limit! I'm i correct in understanding that only the first item listed "atomic transformation functions in transactions" is actually unique to transactions? That is, you could do spec based validations on data before it's transacted but with a transaction function you can do during the transaction.


I think the second one is unique too

Drew Verlee15:11:40

I couldn't find anything in the docs about it. I assume the just add a spec validation in the middle of the transaction function. The same way you could add any valid clojure code.


What is the minimal iam role for connecting and reading datomic? Is there such a role by default? Ah now I see there is an admin and a readonly policy


@drewverlee As an example - you can verify a cardinality 1 relationship with a schema, but i don’t think you can validate a foreign key relationship without transaction functions

Drew Verlee00:11:16

That makes sense.


You can't reliably validate anything that has a multi-datom dependency without atomicity. If you're validating it while something else is modifying it then your final transaction will result in potentially invalid data. You can use CAS to mitigate that as long as you CAS on the stuff you read as well as the stuff you write. I have a system where there is a central owner entity for each account. I find transactor functions hurt throughput too much when they contain a lot of validation, so I instead do an optimistic concurrency control where I CAS on a counter (no history) on that entity to increase it by one from what I read before starting validation. I'm essentially treating that counter like an account-level db lock. That ensures only one tx can run per account at a time even though most of the work is done outside the tx.

Drew Verlee18:11:27

Very interesting, i'll have to give that some thought.