LeanKit-Labs / riaktive

A Riak API abstraction built on riakpbc that aims for simplicity.
MIT License
2 stars 7 forks source link

Consider additional levelup compatibility #21

Open Downchuck opened 9 years ago

Downchuck commented 9 years ago

Riaktive get/put make for a good drop-in replacement for riakdown. It'd be nice to see a compatibility layer for the rest of the levelup api.

Namely, createKeyStream, createReadStream and batch.

arobson commented 9 years ago

Hi @Downchuck - if you're interested in submitting a PR for those features, I'll take a look at it. Riaktive presently provides a way to get keys and docs on demand using callbacks. There isn't parity for batching via Riak's API (I suppose you could pretend it was an atomic batch, but it isn't). At this point, I'm not sure I understand the value of trying to maintain feature parity with a different storage API.

Downchuck commented 9 years ago

I'm not sure where to push/contribute for my particular use case -- just wanting another levelup backend. riakdown fell apart on me, in our testing: we switched over to riaktive now that the dependencies are simpler.

At present we are just using get/put and level promise means that the riaktive API is already the same as the levelpromise+levelup API.

-Charles

Downchuck commented 9 years ago

I'll look toward a PR next week -- my thinking is that I'd add a levelup() method, it'd bring in those methods I described as well as "sublevel", which simply maps to bucket.

The value is largely in development: being able to switch from riak to memory-storage is very valuable. That said, the value is also in flexibility, being able to switch from riak to any other DB in the level ecosystem without maintaining a code branch specific to riak (apart from good stuff like "ping").

This is the constructor in levelup ecosystem:

var levelup = require('levelup');
var sublevel = require('level-sublevel');
var levelpromise = require("level-promise");
var memdown = require('memdown');
var db = levelpromise(sublevel(levelup(':memory:', { db: memdown })));