Current situation:
- Leveldown needs to be manually opened, and you have to wait for that to succeed.
- Deferred-Leveldown is a temporary leveldown tgat queues operations until it's given the real leveldown
- Levelup initially hosts a deferred-leveldown, opens the real leveldown, then tells deferred-leveldown about it and replaces that with the real leveldown
- If you close the db via levelup, leveldown is closed and deferred-leveldown is put in place again.
What needs to change:
- Levelup should be able to be accept closed, opening, open and closing leveldowns
- Lazy open / close of leveldowns has been requested
- LevelUp already handles too many cases / conditions
Proposals:
deferred-leveldownshould take care of opening the db, not levelup, so levelup just expects an open db- add
.wrapperoption to levelup, which defaults torequire('deferred-leveldown'), but you could for example pass the hypothetical wrapper{ wrapper: require('level-lazy-open') }to override that
More vague proposals:
- get rid of
openingandclosingin levelup, only haveopenandclosed
Ideas:
- research how other libs do this, for example
redis