janearc / riak-dc Goto Github PK
View Code? Open in Web Editor NEWA very, very tiny NodeJS interface to Riak
License: Other
A very, very tiny NodeJS interface to Riak
License: Other
it would be nice to have a call to riak that returned an easy-to-use object that would give you e.g., the Riak version. the api spec is mostly-clear.
porting riak-dc to plugsuit helps us get rid of nopt
➜ riak-dc git:(gender-neutral) npm test
> [email protected] test /Users/jane/asdjkads/riak-dc
> mocha
✓ Riak package initialised with test values
16:50:10.007 [ INFO] [ xit] - 034aeca7 closed 1s
✓ ping
16:50:10.029 [ INFO] [ xit] - 15b13701 closed 0s
✓ get_buckets
16:50:10.033 [ INFO] [ xit] - d9f8fbb3 closed 0s
✓ put_tuple (without key)
16:50:10.035 [ INFO] [ xit] - 43f511ae closed 0s
✓ put_tuple (with key)
16:50:10.036 [ INFO] [ xit] - d055112e closed 0s
1) get_tuple (0-byte)
16:50:10.039 [ INFO] [ xit] - f7b09d6f closed 0s
✓ get_tuple
16:50:10.041 [ INFO] [ xit] - 79b7d1f0 closed 0s
✓ get_keys
16:50:10.044 [ INFO] [ xit] - d34a245c closed 0s
2) del_tuple
7 passing (2s)
2 failing
1) get_tuple (0-byte):
TypeError: Cannot read property 'constructor' of undefined
at test/riak-dc.js:75:12
at _fulfilled (node_modules/q/q.js:834:54)
at self.promiseDispatch.done (node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (node_modules/q/q.js:796:13)
at node_modules/q/q.js:604:44
at runSingle (node_modules/q/q.js:137:13)
at flush (node_modules/q/q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
2) del_tuple:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
npm ERR! Test failed. See above for more details.
that's kind of embarrassing, jane...
It should be possible to, upon each request, assign it a request number (a guid maybe?) and then delete that request number when the 'end'
event gets called. Accordingly that would allow you to check:
while (riak.request_oustanding( request_id )) { /* snooze */ }
This would also allow you to do something like:
for (var req_ids = riak.requests_outstanding(); req_ids.length; ) {
console.log( riak.request_status( req_ids.pop() ) );
}
for the record I really super hate that I have to even consider this sort of BS but that's just how the node works.
So entire hacker-weeks have been spent debugging shit that ONLY EXISTS IN TESTS because it's not "A Real Riak™." The solution to this is to just use travis or circle or whatever. The tests will be slower, but they will be against Riak, and not against nock or whatever.
This will take a while.
it is very difficult to debug rrm
and riak-dc
without using a proxy (because node is kind of shit at telling you what it's doing). it's not clear that the native http
understands it, but there's a stackoverflow kind-of-hackish way to do it.
So if you have an empty record in Riak, it actually doesn't return anything meaningful:
fetch:sendak jane$ curl -i -XGET 'http://localhost:8098/riak/User/HeJCUY1MGNTlmaSKvSDhPkESIzp'
HTTP/1.1 200 OK
X-Riak-Vclock: a85hYGBgzGDKBVIcypz/fobY8LFnMCUy5rEyCPgePcuXBQA=
Vary: Accept-Encoding
Server: MochiWeb/1.1 WebMachine/1.10.5 (jokes are better explained)
Link: </riak/User>; rel="up"
Last-Modified: Wed, 29 Oct 2014 11:35:44 GMT
ETag: "42IVUQgTmdtX7EM1CMopca"
Date: Mon, 03 Nov 2014 21:03:34 GMT
Content-Type: application/json
Content-Length: 0
This means that riak-dc
doesn't actually return anything, which is disconcerting. The consequence of this is if you say, hey riak, show me all the keys you have in bucket User
, it will dutifully give you a list:
fetch:sendak jane$ sendak rrm --get-objects --object-type 'User'
looking for User objects
fetching key KwdSDk0z0l3uBUS2xaUvaCn6FYi
fetching key QtSbQHoKC8LXf1vFBFkKJQtSmzE
fetching key 5sQMmck0Fo6pVTjHyhkebWCVW9U
fetching key HeJCUY1MGNTlmaSKvSDhPkESIzp
fetching key 9betCTdgSR6C5WumoMTZD17YdXa
fetching key YG3h2PLiVwlRsbxMIxAGEyc3rRx
fetching key 2Anz05t6qGabL1iI0bznDV7SiGy
fetching key EcfivAt9kFn4fwqZYgLSrkms9Ki
fetching key 2zLfr1z7uSuK2dMokWGb85PQb8l
fetching key 8YxgNqH2XAd9lSXFfS1kRm74gAd
fetching key THIS_KEY_HAS_DATA
fetching key 4YAflwVD54khdLaMfrYzQ1QAsQG
fetching key aU7LRjU38v0UwUnjRclp4xVkdhw
fetching key 4zeUQklE7QUJbOMR3TsInYqXxYO
fetching key 6W1F8yHOFGM3ekhxlGgytKQ36WH
fetching key 13uxpyaVmaJ8qfbnxpJNNCZdfmc
And consequently will return zero data because the http
backend doesn't ever actually get a data
event; it just gets a HTTP/1.1 200 OK
. Boy, this is shitty. Probably the best thing to do is return undef for those empty records. The empty string is probably not the right thing to return.
A sort of zen question - if it is in Riak but has no value, is it an actual thing? What of tombstones?
add riak.ping()
to the api for purposes of nops/completeness.
See Sendak #33
having lots of
exports.foo = foo
exports.bar = bar
stuff is icky.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.