Skip to contentSkip to conversation

(New) librados: node.js bindings

Ceph - Feature #4230 Alexandre Marangone 2 participants 2 messages Feb 23, 2013 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi Wido,

Also cc'ing ceph-devel.

Few months ago I started to write node bindings to librados. No specific use case either, just curious to learn a little bit more about v8 and librados.

My first work was to do a 1:1 wrapping, but it wasn't javascripty enough. I started over and was able to do stuff like:
var librados = require('./build/Release/nrados');
var rados = new librados.Rados({
'user': 'admin',
'keyring': '/etc/ceph/keyring',
'monitors': '[ 192.168.0.20 ]'
});

var ioctx = new librados.IoCtx();
rados.connect(function (err) {
if (err)

       throw err;
   rados.ioctx_create('mypool', ioctx, function (err) {
     if (err)
       throw err;
     ioctx.write_full('myobject1', 'aa');

});
});
Which is better, but still, clumsy (I want to get rid of ioctx_create). I need to put some thoughts into the overall design.

I didn't touch the code for about two months, and couldn't find it this morning. As soon as I figure out where it is, I'll create a github repo.

Of course, thoughts and suggestions are welcome.

--
Alexandre

Quoted 38 lines · On Fri, Feb 22, 2013 at 2:42 AM, <[email protected]> wrote:

Issue #4230 has been reported by Wido den Hollander.
________________________________

Feature #4230: librados: node.js bindings

Author: Wido den Hollander
Status: New
Priority: Low
Assignee:
Category: librados
Target version:
Source: Community (dev)
Tags:
Reviewed:

Although I don't have a use-case at this specific point it would be very cool to have node.js bindings.

From the docs it seems pretty simple to write these bindings and make cool stuff with it.

I'm just opening the feature here so that it shows up and can be picked up:

Some reference docs:

http://nodejs.org/api/addons.html#addons_wrapping_c_objects
http://www.slideshare.net/nsm.nikhil/writing-native-bindings-to-nodejs-in-c
https://github.com/nikhilm/jsfoo-pune-2012

Without bindings you would be able to use node-ffi, but I think native bindings would be cleaner: https://github.com/rbranson/node-ffi

________________________________

You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here:
http://tracker.ceph.com/my/account

#2 lore raw
Quoted 1 line · Alexandre Marangone

Of course, thoughts and suggestions are welcome.

Oo, this is nice. A while back I built a cls_v8 object class to play with, but never got around to working on a front-end. The motivation was to be able to write things like this in the client:

App.js
------

function plugin() {

  function helper(args) {
    /* do stuff */
  }

  function handler1(input, output) {
    /* do stuff */
  }

  function handler2(input, output) {
    /* do stuff */
  }

}

/* serialize the plugin as a string */
var myplugin = plugin.toString();

rados.ioctx_create('mypool', ioctx, function (err) {
if (err)

    throw err;
  command = {
    'script': myplugin,
    'handler': 'handler1',
    'input': 'hello',
  };

/* run the plugin in OSD using V8 JIT compilation */ ioctx.exec('myobject1', 'cls_v8', 'eval', command);

});

- Noah

Quoted 46 lines

--
Alexandre

Quoted 32 lines · On Fri, Feb 22, 2013 at 2:42 AM, <[email protected]> wrote:

Issue #4230 has been reported by Wido den Hollander.
________________________________

Feature #4230: librados: node.js bindings

Author: Wido den Hollander
Status: New
Priority: Low
Assignee:
Category: librados
Target version:
Source: Community (dev)
Tags:
Reviewed:

Although I don't have a use-case at this specific point it would be very cool to have node.js bindings.

From the docs it seems pretty simple to write these bindings and make cool stuff with it.

I'm just opening the feature here so that it shows up and can be picked up:

Some reference docs:

http://nodejs.org/api/addons.html#addons_wrapping_c_objects
http://www.slideshare.net/nsm.nikhil/writing-native-bindings-to-nodejs-in-c
https://github.com/nikhilm/jsfoo-pune-2012

Without bindings you would be able to use node-ffi, but I think native bindings would be cleaner: https://github.com/rbranson/node-ffi

Quoted 6 lines

________________________________

You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here:
http://tracker.ceph.com/my/account

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html