Skip to content

Add list objects in a pool #12

Description

@wcchh

Hi, I need a list function about specified pool, and I have added this function at my local for test. Could someone could help review it and let it be support function? Thanks in advance~

[at rados.h]
...
class Ioctx : public node::ObjectWrap {
...
static NAN_METHOD(aio_objects_list);
}

[at rados.cc]
...

define ENOENT 2

NAN_METHOD(Ioctx::aio_objects_list) {
NanScope();

if (args.Length() < 1 ||
!args[0]->IsString()) {
return NanThrowError("Bad argument.");
}

Ioctx* obj = ObjectWrap::Unwrap(args.This());
if ( !obj->require_created() ) NanReturnNull();

rados_list_ctx_t h_ctx;
//Start listing objects in a pool.
int err = rados_objects_list_open(obj->ioctx, &h_ctx);
if (err < 0) {
return NanThrowError("open list failed.");
}

Local ret_list = NanNew();
uint32_t array_id = 0;
//Get the next object name and locator in the pool.

while(0 <= err) {
const char *obj_name;
err = rados_objects_list_next(h_ctx, &obj_name, NULL);
if (err == 0) {
ret_list->Set(array_id, NanNew(obj_name));
array_id++;
}
}
rados_objects_list_close(h_ctx);

if (err < 0 && err != -ENOENT) {
return NanThrowError("list_next failed.");
}

NanReturnValue(ret_list);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions