From a5d5559f8ea9fc60b01bfe8c9b2084073ec2b2b2 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 26 Jan 2025 01:18:56 +0300 Subject: [PATCH] Add get_immediate_commit() to the node.js binding --- node-binding/addon.cc | 5 +++++ node-binding/client.cc | 11 +++++++++++ node-binding/client.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/node-binding/addon.cc b/node-binding/addon.cc index 480edf91..6c5d5e32 100644 --- a/node-binding/addon.cc +++ b/node-binding/addon.cc @@ -19,6 +19,7 @@ NAN_MODULE_INIT(InitAddon) Nan::SetPrototypeMethod(tpl, "on_ready", NodeVitastor::OnReady); Nan::SetPrototypeMethod(tpl, "get_min_io_size", NodeVitastor::GetMinIoSize); Nan::SetPrototypeMethod(tpl, "get_max_atomic_write_size", NodeVitastor::GetMaxAtomicWriteSize); + Nan::SetPrototypeMethod(tpl, "get_immediate_commit", NodeVitastor::GetImmediateCommit); //Nan::SetPrototypeMethod(tpl, "destroy", NodeVitastor::Destroy); Nan::Set(target, Nan::New("Client").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); @@ -66,6 +67,10 @@ NAN_MODULE_INIT(InitAddon) Nan::Set(target, Nan::New("ENOSYS").ToLocalChecked(), Nan::New(-ENOSYS)); Nan::Set(target, Nan::New("EAGAIN").ToLocalChecked(), Nan::New(-EAGAIN)); + Nan::Set(target, Nan::New("IMMEDIATE_NONE").ToLocalChecked(), Nan::New(IMMEDIATE_NONE)); + Nan::Set(target, Nan::New("IMMEDIATE_SMALL").ToLocalChecked(), Nan::New(IMMEDIATE_SMALL)); + Nan::Set(target, Nan::New("IMMEDIATE_ALL").ToLocalChecked(), Nan::New(IMMEDIATE_ALL)); + // Listing handle tpl = Nan::New(NodeVitastorKVListing::Create); diff --git a/node-binding/client.cc b/node-binding/client.cc index 43db7b25..63e4df91 100644 --- a/node-binding/client.cc +++ b/node-binding/client.cc @@ -314,6 +314,17 @@ NAN_METHOD(NodeVitastor::GetMaxAtomicWriteSize) info.GetReturnValue().Set(Nan::New(vitastor_c_inode_get_block_size(self->c, INODE_WITH_POOL(pool, 1)))); } +// get_immediate_commit(pool_id) +NAN_METHOD(NodeVitastor::GetImmediateCommit) +{ + TRACE("NodeVitastor::GetImmediateCommit"); + if (info.Length() < 1) + Nan::ThrowError("Not enough arguments to get_immediate_commit(pool_id)"); + NodeVitastor* self = Nan::ObjectWrap::Unwrap(info.This()); + uint64_t pool = get_ui64(info[0]); + info.GetReturnValue().Set(Nan::New(vitastor_c_inode_get_immediate_commit(self->c, INODE_WITH_POOL(pool, 1)))); +} + void NodeVitastor::on_read_finish(void *opaque, long retval, uint64_t version) { TRACE("NodeVitastor::on_read_finish"); diff --git a/node-binding/client.h b/node-binding/client.h index cd10dbd0..0a52fd7c 100644 --- a/node-binding/client.h +++ b/node-binding/client.h @@ -29,6 +29,8 @@ public: static NAN_METHOD(GetMinIoSize); // get_max_atomic_write_size(pool_id) static NAN_METHOD(GetMaxAtomicWriteSize); + // get_immediate_commit(pool_id) + static NAN_METHOD(GetImmediateCommit); // // destroy() // static NAN_METHOD(Destroy);