ipfs / go-ds-leveldb

An implementation of go-datastore using leveldb
MIT License
37 stars 21 forks source link

Support Asynchronous Writing #38

Open aschmahmann opened 4 years ago

aschmahmann commented 4 years ago

LevelDB internally supports both synchronous and asynchronous datastore writes (via the WriteOptions struct). However, to support our Datastore interface's definition of an asynchronous datastore we need to support the Sync(prefix ds.Key) function which syncs to disk, at least, all keys hierarchically under prefix.

As goleveldb only supports syncing the database during writes, and not at an arbitrary time, we haven't yet implemented this. While we could try to work around this limitation by synchronously writing to some preset key (as mentioned in https://github.com/ipfs/go-ds-leveldb/pull/36#issuecomment-559881795), it would be much cleaner and would have less edge cases if a Sync function were exposed by goleveldb.

If something like syndtr/goleveldb#310 was to be merged this would be a very straightforward fix.