-
-
Notifications
You must be signed in to change notification settings - Fork 267
isEmbedded() expose what sort of contract the leveldown can provide. #279
Comments
👍 Seems reasonable to me. Something @fritzy had brought up in the past was adding some kind of feature detection to *down backends, so this could potentially lay the groundwork for future development in that direction as well. |
As discussed at nodeconfeu, 👍 for me. |
+1 to the general idea, embedded is the wrong word though isn't it? couldn't a non-embedded db support all of abstract-leveldown? |
@juliangruber yes, but it wouldn't support the implicit assumption of embeddedness - that all incoming data passes through this instance. |
ah ok. agreed, this is good to know. thinking about future demands we could simplify by implementing a broader compatibility function, like: db.has('embedded')
db.has('snapshots')
db.has('batches') etc |
+1 to Julian's suggestion! On Saturday, September 13, 2014, Julian Gruber [email protected]
Paolo Fragomeni github.com/hij1nx |
Or just |
yeah, the exact api is probably best discussed in a pr. but big +1 to the idea |
+1 for Julian's idea. It would also be nice if the abstract-leveldown tests checked for such things before running certain tests, e.g. for the snapshot test. |
...and if we had a module that takes those compatibility results and generates a big badge for readmes and a small one for the levelup wiki |
+1000 |
taking a step back what is the isEmbedded supposed to check for, that only one process can connect to it at once? because sqlite3 is embedded, but it can have multiple processes have it open which work screw up the ability to use sublevel |
@calvinmetcalf good point... maybe it should be So we want to know if the backend is strictly single process... this is more important than being embedded, per se. Although, this is often implied by being embedded... |
isEmbedded looks nicer. But I get the point of isSingleProcess. How about |
Sounded like there was a lot of +1's for Julian's idea for db.has('exclusive-access') Although a |
I disapprove of a using a function because it implies the result might be dynamic - this should be static - is depends on the implementation of the database, which doesn't dynamically change. (I realize that I originally suggested a function - but in the pr I made a boolean property: Level/leveldown#128) I agree with @chesles that But also, although there are other things we could put in the supports object, there isn't actually a need for any other case than exclusive... |
A: "hey, i heard there a different backends for levelup, some really crazy like s3 and mysql. don't they not support all the features?" I'm for db.supports as an object. |
okay so what are the assurances that leveldb gives us that other backends might not? I'm thinking exclusive access, snapshots (on iterators), and batches. |
binary keys / values |
unlimited size of keys / values |
backend implementors probably know best here |
I feel there is some danger in adding a bunch of things here that are currently hypothetical and don't represent a clear and present danger to some level-* module. (i.e. cause it's tests to fail) |
|
those sound good. i don't care too much which features we add, it's only important to me that we make this feature detection generic |
@calvinmetcalf can you be explicit about which backends and which modules are affected by a particular issue, such as buffers Snapshots affect pull-level and level-live-stream if you read both old and new records in one stream. |
so multi access is something that effects backends, it either throws an error or doesn't, requiring single access is something that effects plugin-ins. sqldown can handle multi-access, any sort of sublevel based indexing requres sole access no mater what the backend. buffers effects downs in the browser sometimes, they return strings instead of buffers, I assume these can be context dependent so levelup returns something about what the default return type is |
It sounds like we have 2 sets of things: features a particular backend supports, and features a particular plugin needs support for. Building off the idea for a module to generate compatibility badges, if each plugin defined a |
everything should be able to provide buffers, although it might be necessary to do some wacky polyfil. |
It's not that they don't do them right it's that they do them differently
|
@calvinmetcalf If it would be easier, we could just release a major version for localstoragedown/memdown and then return buffers instead of strings. Admittedly, this is probably something we should add as an abstract-leveldown test, so that we could define it as correct behavior, instead of just fixing it in Pouch as we've lazily done up till now. |
Next step here is for someone to PR against abstract-leveldown with a test case that (1) checks that We can bikeshed I'm +1 on limiting it to only what is needed by actual extensions at the moment, with |
Though some differences between |
Closing in favor of Level/community#42 (which summarizes this thread). |
After seeing a talk at nodeconf eu that used sqldown I realized it would be impossible to stop people using levelup with non-embedded back ends, and having a discussion of this #255 scale every time would only turn me into a grumpy old bastard...
Then I realized there was a simpler possibility, we add an
db.isEmbedded()
method this would be exposed on the levelup and leveldown instances, and modules that do not support non-embedded databases can throw with a helpful error message (that links to documentation on the distinction between embedded and service databases)Also, there would be documentation on isEmbedded() and it would be easy to do a few pull requests to add isEmbedded to the various leveldowns. So it would be simpler than reimplementing all of level #270 (this will take a long time, anyway) but still allow people using level in other ways, such as @nlf @adambrault @fritzy are doing.
The text was updated successfully, but these errors were encountered: