Description
This is just an idea at this point, briefly discussed offline; we're not committing to anything. The premise: make any abstract-leveldown
implementation a standalone, ready-to-go database.
Refactorings in the past years have increased modularity. It has allowed us to clean up various internals. That said, now that we have, there are downsides to the current architecture, with its many layers:
- Adding custom behavior to e.g.
level
means having to peel off layers first, then add them back (most notably insubleveldown
- that code is gnarly) - The layers share API surface with treacherously subtle differences (e.g.
leveldown
by itself returns Buffers by default,level(up)
returns strings by default). - There are 4 forms of "encoding" now:
encoding-down
, serialization,asBuffer
, and whatever the underlying storage does (e.g. IDB returning a Buffer as Uint8Array). Yet for anabstract-leveldown
implementation there's no builtin primitive to decode/deserialize data. - Breaking changes in one layer typically bubble up, leading to what we call "the release dance". Prior to that, canary testing is often required because we can't foresee everything.
- A rabbit hole of documentation and changelogs (
level
links tolevelup
links toencoding-down
links tolevel-codec
gives an example aboutleveldown
links tolevel
- you get the point) - Double allocation of callback functions, options objects, etc.
- No builtin mechanism for asynchronous hooks (this could be achieved as another
abstract-leveldown
layer, but that doesn't make it available to levelup per se) (related: plugin extension points: merge level-hooks / level-sublevel #44). - Implementing manifests (Requirements for manifests #42) is hard.
Back to the idea: there are many open questions. Making a POC is probably the best way forward. To be clear: I don't want it to be a big batteries-included database. I think what we need are simpler primitives to enable composing (and maintaining!) such a database. Some "batteries" could be worth including, if they provide a foundation for userland modularity.
We have been recommending people to use levelup
, and more so, level
and friends, which is a clear indication that much of the functionality belongs in a single core component. Or to put it in other words, a single shell (the public API of abstract-leveldown
) around a nut (the private API of abstract-leveldown
).