Skip to content

Merge levelup into abstract-leveldown #58

Closed

Description

@vweevers

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:

image

  • Adding custom behavior to e.g. level means having to peel off layers first, then add them back (most notably in subleveldown - 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 an abstract-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 to levelup links to encoding-down links to level-codec gives an example about leveldown links to level - 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).

Activity

  1. ralphtheninja commented on Dec 30, 2018

    @ralphtheninja
    Member

    I'm all for simplifying. There's also an issue of performance. Maybe we could benchmark the hell out of level and compare with a benchmark done on a POC.

    • What would this mean for current implementations of abstract-leveldown?
    • Are we aiming for a smooth transition for implementations?
    • How would encodings fit in? (it must be easy to pull in e.g. bytewise and charwise).

    Love the picture btw. This style is really nice. We should reuse it for documentation, blog post etc. How did you make it?

  2. vweevers commented on Dec 31, 2018

    @vweevers
    MemberAuthor

    Love the picture btw. This style is really nice. We should reuse it for documentation, blog post etc. How did you make it?

    Photoshop. I wanted to try its 3D features. And I'm never gonna do it again, lol. Took 10 crashes and retries and then 20 minutes waiting time just to render some damn plastic material 😄

  3. vweevers commented on Jan 1, 2019

    @vweevers
    Author
  4. vweevers commented on Mar 30, 2019

    @vweevers
    MemberAuthor

    Are we aiming for a smooth transition for implementations?

    I say yes. The first version can and should be a drop-in replacement. To keep all the history and get regression tests for free.

    Rough roadmap

    The fork provides a starting point for later breaking changes, and a turning point for dependents: when they make the switch from abstract-leveldown to abstract-level, you no longer need levelup. Up until this point abstract-level is a drop-in replacement for abstract-leveldown that is also still safe to be wrapped by levelup - yet behaves the same as levelup if you don't. This is very optimistic, mind you. I'm sure there will be stumbling blocks along the way that may force us to reconsider this approach.

    Let's make encodings "phase 2".

  5. pinned this issue on Mar 31, 2019
  6. vweevers commented on Apr 6, 2019

    @vweevers
    Author
  7. vweevers commented on Apr 28, 2019

    @vweevers
    Author
  8. vweevers commented on Apr 28, 2019

    @vweevers
    Author
  9. vweevers commented on Apr 28, 2019

    @vweevers
    MemberAuthor

    💡 If abstract-leveldown implementations are encoding-aware then leveldown could implement the IndexedDB comparator (which sorts almost the same as bytewise/charwise) natively.

  10. changed the title [-]Merge level(up) functionality into abstract-leveldown[/-] [+]Merge levelup into abstract-leveldown[/+] on Aug 14, 2019
  11. vweevers commented on Jan 2, 2021

    @vweevers
    MemberAuthor

    Calling this abstract-level going forward. It ain't down, it ain't up, it's level.

  12. vweevers commented on Jan 2, 2021

    @vweevers
    MemberAuthor

    Let's make encodings "phase 2".

    I think it will be easier to do this the right way from the get-go. I want to support encodings out of the box, replacing both _serialize() (which is just another encoding API with a different name) and asBuffer (which in a way expresses a relation between codecs, for example that json is also utf8). I'm working out the details.

  13. vweevers commented on Nov 9, 2021

    @vweevers
    MemberAuthor

    This thread got messy with my frequent edits and inline task lists. Continuing at https://github.com/Level/abstract-level.

  14. unpinned this issue on Jun 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions