Skip to content

Instantly share code, notes, and snippets.

@juliangruber
Last active October 16, 2015 20:19
Show Gist options
  • Select an option

  • Save juliangruber/218790f192aa41922076 to your computer and use it in GitHub Desktop.

Select an option

Save juliangruber/218790f192aa41922076 to your computer and use it in GitHub Desktop.
level open / close situation

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-leveldown should take care of opening the db, not levelup, so levelup just expects an open db
  • add .wrapper option to levelup, which defaults to require('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 opening and closing in levelup, only have open and closed

Ideas:

  • research how other libs do this, for example redis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment