GithubHelp home page GithubHelp logo

API about cockroach HOT 9 CLOSED

cockroachdb avatar cockroachdb commented on August 27, 2024
API

from cockroach.

Comments (9)

andybons avatar andybons commented on August 27, 2024

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.

andybons avatar andybons commented on August 27, 2024

Additionally, as this isn’t really a bug, I’m closing in favor of moving to [email protected]

from cockroach.

spencerkimball avatar spencerkimball commented on August 27, 2024

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.

mcollina avatar mcollina commented on August 27, 2024

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.

spencerkimball avatar spencerkimball commented on August 27, 2024

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.

mcollina avatar mcollina commented on August 27, 2024

All the levelup API is supposed to be atomic, so batch is how transaction are made. Does it make sense?

from cockroach.

spencerkimball avatar spencerkimball commented on August 27, 2024

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.

mcollina avatar mcollina commented on August 27, 2024

@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.

spencerkimball avatar spencerkimball commented on August 27, 2024

Thanks Matteo, I'll do that.

from cockroach.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.