Comments (9)
Hi @mcollina,
The key/value REST API is not fully documented and—as Cockroach is still in alpha—still prone to breaking changes. That said, you can peruse the code in https://github.com/cockroachdb/cockroach/blob/master/kv/rest.go to see what the endpoints look like. You can use protocol buffers or pure JSON as the wire format.
from cockroach.
Additionally, as this isn’t really a bug, I’m closing in favor of moving to [email protected]
from cockroach.
Andy's suggestion is the REST API. That may be adequate for what you have in mind, but maybe you're interested in something closer to the capabilities of levelup.
Still, I'm not completely clear on what you're suggesting. Cockroach could be a replacement for the leveldb backend which node-levelup allows your node.js apps to talk to. If you wanted to do that, you'd need to write something which might look similar to node-levelup; call it node-roach. It would have a different API though, as the functionality which Cockroach exposes is sufficiently different from leveldb.
With node-levelup, you're talking directly through to a resident database library using local storage. With Cockroach, you're talking to a gateway which leads to a distributed cluster. The communication to the gateway is via protobufs or JSON over HTTP. The Go package which is the analog of what would be required to implement in node-js is here: https://godoc.org/github.com/cockroachdb/cockroach/client. Look at the "Package Files" section to see the actual implementation. Without counting comments or the http transport, it's only 300 lines. We certainly intend to write a javascript client, but if you'd like to help out that'd be appreciated.
from cockroach.
Still, I'm not completely clear on what you're suggesting. Cockroach could be a replacement for the leveldb backend which node-levelup allows your node.js apps to talk to. If you wanted to do that, you'd need to write something which might look similar to node-levelup; call it node-roach. It would have a different API though, as the functionality which Cockroach exposes is sufficiently different from leveldb.
How it is different? I was checking the API. LevelUP can work on top of LevelDB (and flavours), MongoDB, Redis, DynamoDB, and a lot more. Here is the API I would love to implement: https://github.com/rvagg/abstract-leveldown.
It seems that it can easily be mapped to LevelUp.
What it needs are:
- get/put/delete (as in leveldb)
- batch of the above
- iterator upon ranges of keys
From my understanding of Cockroach, it seems you have these features.
from cockroach.
Ah I see what you're after. But is level up really providing the best API for a key value store? I'd be inclined to include transactions!
from cockroach.
All the levelup API is supposed to be atomic, so batch is how transaction are made. Does it make sense?
from cockroach.
Sure, and you'd implement the batch if Cockroach is the backend data store by actually using a transaction since the batch could contain writes to different nodes in the distributed cluster. However, most transactional operations involve reading and then logic in the application which generates appropriate writes. Making the reads and subsequent writes transactional isn't doable with a write batch.
from cockroach.
@spencerkimball you are absolutely right. Level is not the perfect interface for Cockroach. However the Level ecosystem is so big, that a lot of people will find it really useful. Have a look at LevelGraph, a Graph database that sits on that.
I'll get back to it when the API is a little more stable ;). Please, ping me back when you want to write a pure-node or Level-compatible JS driver ;).
from cockroach.
Thanks Matteo, I'll do that.
from cockroach.
Related Issues (20)
- pkg/ccl/logictestccl/tests/multiregion-9node-3region-3azs-tenant/multiregion-9node-3region-3azs-tenant_test: TestCCLLogic_partitioning_hash_sharded_index_mr failed
- Sentry: panic.go:770: runtime error: slice bounds out of range [:16] with capacity 5 (1) attached stack trace -- stack trace: | runtime.gopanic | GOROOT/src/runtime/panic.go:770 | runtime.goP...
- pkg/ccl/testccl/sqlccl/sqlccl_test: TestExplainRedactDDL failed
- raft: TestNodeProposeWaitDropped failed
- roachtest: costfuzz/seed-multi-region failed
- roachtest: disk-stalled/wal-failover/among-stores failed HOT 1
- pkg/ccl/testccl/sqlccl/sqlccl_test: TestExplainRedactDDL failed
- pkg/ccl/backupccl/backuprand/backuprand_test: TestBackupRestoreRandomDataRoundtrips failed
- build: store microbenchmark results in GCS HOT 1
- roachtest: restore/online/workload=true/tpcc/350GB/gce/inc-count=0/nodes=4/cpus=8 failed HOT 1
- ccl/crosscluster/logical: TestRandomStream failed
- roachprod-microbench: publish comparison results to InfluxDB HOT 1
- server,sql: Remove `OptionalNodesStatusServer` usage from `crdb_internal.kv_{node_status,store_status}` HOT 1
- microbenchmarks: dashboards HOT 1
- internal error: comparison overload not found (ge, unknown, unknown) HOT 4
- Sentry: fold_constants_funcs.go:677: function current_schema() not defined (1) assertion failure Wraps: (2) attached stack trace -- stack trace: | github.com/cockroachdb/cockroach/pkg/sql/opt/norm...
- Create new HTTP API for retrieving table metadata
- Create new HTTP API for retrieving database metadata
- Create new HTTP API for retrieving the table metadata update job status
- Create new HTTP API to triggering the table metadata update job
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cockroach.