NLnetLabs / kvx

Abstraction layer over various key-value store backends in Rust
BSD 3-Clause "New" or "Revised" License
6 stars 1 forks source link

Add KeyValueStore::execute. #38

Closed partim closed 1 year ago

partim commented 1 year ago

This PR adds a method KeyValueStore::execute that runs a closure as a transaction but allowing it to return a closure.

partim commented 1 year ago

This method could become KeyValueStore::transaction if drop the impl KeyValueStoreBackend for KeyValueStore. I think it would, in fact, make sense to drop all the backend impls for it and move to regular methods. If nothing else this will save you from having to import those traits. I don’t think someone wants to write code that is generic over a backend but also needs to accept the ‘full store’?

timbru commented 1 year ago

This will help me to achieve the following:

Calling it execute rather than transaction is probably better because we do not have proper transactions in all implementations.