Yeah I can see this being useful. I’ve been thinking of making some experimental changes to the nodejs bindings to support realtime change feeds of key ranges. With a feature like this it would be much simpler to do stuff like this:
- The bindings can expose a
beforeCommit
hook to user code. This is the only change we need in the bindings. - A realtime change feed extension can then query back the set of local mutations and write metadata to a more durable operation log, or whatever.
As for encoding, the simplest implementation would be to just have the mirrored set of key/value pairs under \xff\xff
that were written. So if a user does tn.set('x', 'hi')
then I should later be able to tn.getRange('\xff\xff' + 'mutations')
(or whatever) and get back [['\xff\xff' + 'mutations' + 'x', 'hi'], ...]
. Then I can just strip off the prefix and read back the key/value pairs I set.
The other way to do it would be to have a single key contain all the key/value pair data encoded as tuples, since all bindings have a tuple encoder implementation already.