This is an automated email from the ASF dual-hosted git repository.

laiyingchun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus-website.git


The following commit(s) were added to refs/heads/master by this push:
     new 6db633fc update node client doc (#125)
6db633fc is described below

commit 6db633fcfb9ae4d12c6875d4b8ef7feabfb95846
Author: Samunroyu <[email protected]>
AuthorDate: Sun Nov 16 22:11:18 2025 +0800

    update node client doc (#125)
---
 _docs/en/clients/node-client.md | 254 +++++++++++++++++++++++++++++++++++++++-
 _docs/zh/clients/node-client.md |  58 ++++-----
 2 files changed, 282 insertions(+), 30 deletions(-)

diff --git a/_docs/en/clients/node-client.md b/_docs/en/clients/node-client.md
index f0724128..306d964b 100755
--- a/_docs/en/clients/node-client.md
+++ b/_docs/en/clients/node-client.md
@@ -2,4 +2,256 @@
 permalink: clients/node-client
 ---
 
-TRANSLATING
+# Install the Node.js Client
+Project repository: [Pegasus NodeJS 
Client](https://github.com/apache/incubator-pegasus/tree/master/nodejs-client)
+
+Download and add the client dependency to `package.json`:
+`npm install pegasus-nodejs-client --save`
+
+# Create/Close Client
+## create
+```
+let pegasusClient = require('pegasus-nodejs-client');
+/**
+ * Create a client instance
+ * @param   {Object}  configs
+ *          {Array}   configs.metaServers          required
+ *          {String}  configs.metaServers[i]       required
+ *          {Number}  configs.operationTimeout(ms) optional
+ *          {Object}  configs.log                  optional
+ * @return  {Client}  client instance
+ * @throws  {InvalidParamException}
+ */
+client = pegasusClient.create({
+    metaServers: ['127.0.0.1:34601', '127.0.0.1:34602', '127.0.0.1:34603'],
+    operationTimeout : 5000,
+    log : log,
+});
+```
+- `metaServers` is the list of meta server addresses and is required.
+- `operationTimeout` is the timeout for the current operation in milliseconds, 
default is `1000` ms.
+- `log` is the logger instance.
+  - We use [log4js](https://github.com/log4js-node/log4js-node).
+  - The default logger configuration is in `log_config.js`, as follows:
+  ```
+  let filename = "./logs/"+process.pid+"/pegasus-nodejs-client.log";
+  let logConfig = {
+      appenders: { 
+        pegasus: {
+          type: "file", 
+          filename: filename, 
+          maxLogSize: 104857600, 
+          backups: 10
+        } 
+      },
+      categories: { 
+        default: { appenders: ["pegasus"], level: "INFO" } 
+      }
+  };
+  ```
+  The above configuration means logs of level `INFO` and above are written to 
file, each file is capped at 100MB, and at most 10 backup files are kept.
+  - If you don't want to use the default configuration, redefine the 
`logConfig` object above and pass it as the `log` object when creating the 
client.
+- If the parameters are invalid, an exception will be thrown and subsequent 
operations will stop.
+
+## close
+```
+// close client when you do not need to use it
+client.close();
+```
+
+# API
+## get
+Read a single row.
+```
+/**
+ * Get value
+ * @param {String}      tableName
+ * @param {Object}      args
+ *        {Buffer}      args.hashKey      required
+ *        {Buffer}      args.sortKey      required
+ *        {Number}      args.timeout(ms)  optional
+ * @param {Function}    callback
+ * @throws{InvalidParamException} callback is not function
+ */
+ client.get(
+   tableName,  
+   args, 
+   function(err, result){
+     // if get operation succeed, err will be null,
+     // result.hashKey is hashKey, result.sortKey is sortKey, result.value is 
value
+     // else err will be instance of PException, result will be null
+   }
+ );
+```
+- Required parameters for `get` are table name, `hashKey`, `sortKey`, and 
`callback`.
+- `hashKey`, `sortKey`, and `value` are `Buffer` objects, consistent with 
Pegasus server semantics where key and value are bytes.
+- `timeout` is optional, defaulting to the timeout configured when creating 
the client.
+- On success, `callback` receives `err = null` and `result.value` is the 
retrieved value.
+- On failure, `callback` receives `result = null`.
+- The client does not treat “not found” as an error. If key not found, `err` 
is still `null` and `result.value` is `Buffer('')`.
+
+## set
+Write a single row.
+```
+/**
+ * Set Value
+ * @param {String}      tableName
+ * @param {Object}      args
+ *        {Buffer}      args.hashKey      required
+ *        {Buffer}      args.sortKey      required
+ *        {Buffer}      args.value        required
+ *        {Number}      args.ttl(s)       optional
+ *        {Number}      args.timeout(ms)  optional
+ * @param {Function}    callback
+ * @throws{InvalidParamException} callback is not function
+ */
+ client.set(
+   tableName,  
+   args, 
+   function(err){
+     // if set operation succeed, err will be null
+     // else err will be instance of PException
+   }
+ );
+```
+- Required parameters for `set` are table name, `hashKey`, `sortKey`, `value`, 
and `callback`.
+- `ttl` is the time-to-live in seconds. The default `ttl` is `0`, meaning no 
expiration. For example, `ttl = 86400` means the data expires in 1 day, after 
which the value cannot be read.
+
+## del
+Delete a single row.
+```
+/**
+ * Delete value
+ * @param {String}      tableName
+ * @param {Object}      args
+ *        {Buffer}      args.hashKey      required
+ *        {Buffer}      args.sortKey      required
+ *        {Number}      args.timeout(ms)  optional
+ * @param {Function}    callback
+ * @throws{InvalidParamException} callback is not function
+ */
+ client.del(
+   tableName,  
+   args, 
+   function(err){
+     // if set operation succeed, err will be null
+     // else err will be instance of PException
+   }
+ );
+```
+- Required parameters for `del` are table name, `hashKey`, `sortKey`, and 
`callback`.
+
+## multiGet
+Read multiple rows under the same `hashKey`.
+```
+/**
+ * Multi Get
+ * @param {String}      tableName
+ * @param {Object}      args
+ *        {Buffer}      args.hashKey         required
+ *        {Array}       args.sortKeyArray    required
+ *        {Buffer}      args.sortKeyArray[i] required
+ *        {Number}      args.timeout(ms)     optional
+ *        {Number}      args.maxFetchCount   optional
+ *        {Number}      args.maxFetchSize    optional
+ * @param {Function}    callback
+ * @throws{InvalidParamException} callback is not function
+ */
+ client.multiGet(
+   tableName,  
+   args, 
+   function(err, result){
+     // if operation succeed, err will be null,
+     // result[i].hashKey is hashKey, result[i].sortKey is sortKey, 
result[i].value is value
+     // else err will be instance of PException, result will be null
+   }
+ );
+```
+- Required parameters for `multiGet` are table name, `hashKey`, array of 
`sortKey`, and `callback`.
+- If `sortKeyArray` is an empty array, all sort keys under the `hashKey` will 
be retrieved.
+- `maxFetchCount` limits the maximum number of entries returned, default `100`.
+- `maxFetchSize` limits the maximum bytes returned, default `1000000` bytes.
+
+## batchGet
+Read a batch of entries.
+```
+/**
+ * Batch Get value
+ * @param {String}      tableName
+ * @param {Array}       argsArray
+ *        {Buffer}      argsArray[i].hashKey      required
+ *        {Buffer}      argsArray[i].sortKey      required
+ *        {Number}      argsArray[i].timeout(ms)  optional
+ * @param {Function}    callback
+ * @throws{InvalidParamException} callback is not function
+ */
+ client.batchGet(
+   tableName,  
+   argsArray, 
+   function(err, result){
+     // err will be always be null, result is {'error': err, 'data': result} 
array
+     // if batchGet[i] operation succeed, result[i].error will be null
+     // result[i].data.hashKey is hashKey, result[i].data.sortKey is sortKey, 
result[i].data.value is value
+     // else result[i].error will be instance of PException, result[i].data 
will be null
+   }
+ );
+```
+- Required parameters for `batchGet` are table name, arrays of `hashKey` and 
`sortKey`, and `callback`.
+- Unlike `multiGet`, `batchGet` supports reading values from multiple 
`hashKey`s.
+- `batchGet` waits until all `get` operations in the batch have returned 
before responding.
+- `callback`'s `err` is always `null`.
+- `callback`'s `result` is an array, where `result[i].error` indicates the 
error of the i-th `get` operation, and `result[i].data` indicates its result.
+
+## multiSet
+Write multiple rows under the same `hashKey`.
+```
+/**
+ * Multi Set
+ * @param {String}      tableName
+ * @param {Object}      args
+ *        {Buffer}      args.hashKey           required
+ *        {Array}       args.sortKeyValueArray required
+ *                      {'key' : sortKey, 'value' : value}
+ *        {Number}      args.timeout(ms)       optional
+ *        {Number}      args.ttl(s)            optional
+ * @param {Function}    callback
+ * @throws{InvalidParamException} callback is not function
+ */
+ client.multiSet(
+   tableName,  
+   args, 
+   function(err){
+     // if set operation succeed, err will be null
+     // else err will be instance of PException
+   }
+ );
+```
+- Required parameters for `multiSet` are table name, `hashKey`, array of 
`sortKey`-`value` objects, and `callback`.
+
+## batchSet
+Write a batch of entries.
+```
+/**
+ * Batch Set value
+ * @param {String}      tableName
+ * @param {Array}       argsArray
+ *        {Buffer}      argsArray[i].hashKey      required
+ *        {Buffer}      argsArray[i].sortKey      required
+ *        {Buffer}      argsArray[i].value        required
+ *        {Number}      argsArray[i].ttl          optional
+ *        {Number}      argsArray[i].timeout(ms)  optional
+ * @param {Function}    callback
+ * @throws{InvalidParamException} callback is not function
+ */
+ client.batchSet(
+   tableName,  
+   argsArray, 
+   function(err, result){
+     // err will be always be null, result is {'error': err} array
+     // if batchSet[i] operation succeed, result[i].error will be null
+     // else result[i].error will be instance of PException
+   }
+ );
+```
+- Required parameters for `batchSet` are table name, array of 
`hashKey`-`sortKey`-`value` objects, and `callback`.
+- `callback`'s `err` is always `null`. `result[i].error` indicates the error 
status of the i-th `set` operation.
diff --git a/_docs/zh/clients/node-client.md b/_docs/zh/clients/node-client.md
index 2d8aa583..9289a200 100755
--- a/_docs/zh/clients/node-client.md
+++ b/_docs/zh/clients/node-client.md
@@ -4,7 +4,7 @@ permalink: clients/node-client
 
 # 安装NodeJs客户端
 项目地址:[Pegasus NodeJS 
Client](https://github.com/apache/incubator-pegasus/tree/master/nodejs-client)
-下载并将客户端依赖添加到package.json中:  
+下载并将客户端依赖添加到 package.json 中:  
 `npm install pegasus-nodejs-client --save`
 # 创建/关闭客户端
 ## create
@@ -26,11 +26,11 @@ client = pegasusClient.create({
     log : log,
 });
 ```
-* metaServers为meta server地址列表,为必填项
-* operationTimeout为本次操作的超时时间,单位是毫秒,默认是1000ms
-* log为日志库实例  
+* metaServers 为 meta server 地址列表,为必填项
+* operationTimeout 为本次操作的超时时间,单位是毫秒,默认是1000ms
+* log 为日志库实例  
  * 我们使用日志库 [log4js](https://github.com/log4js-node/log4js-node)
- * 默认使用的日志配置在`log_config.js`文件中,配置如下:
+ * 默认使用的日志配置在 `log_config.js` 文件中,配置如下:
  ```
 let filename = "./logs/"+process.pid+"/pegasus-nodejs-client.log";
 let logConfig = {
@@ -47,8 +47,8 @@ let logConfig = {
     }
 };
  ```
- 上述配置表示,会将错误级别等于及高于INFO级别的日志存储在文件中,每个日志文件最大100M,最多保留10个日志文件
- * 若不想使用默认配置,则需要重新定义如上的logConfig对象,作为创建客户端时的log对象
+ 上述配置表示,会将错误级别等于及高于 INFO 级别的日志存储在文件中,每个日志文件最大 100M,最多保留 10 个日志文件
+ * 若不想使用默认配置,则需要重新定义如上的 logConfig 对象,作为创建客户端时的 log 对象
 * 当参数有误时,会抛出异常,停止后续操作
 
 ## close
@@ -81,12 +81,12 @@ client.close();
    }
  );
 ```
-* get操作的必填参数有表名,hashKey,sortKey和callback
-* hashKey,sortKey和value都是Buffer对象,这与pegasus服务端key与value均为byte的语义保持一致
+* get 操作的必填参数有表名,hashKey,sortKey和callback
+* hashKey,sortKey 和 value 都是 Buffer 对象,这与 pegasus 服务端 key 与 value 均为 byte 
的语义保持一致
 * 超时时间为可选参数,默认为创建客户端时设定的超时时间
-* 当读操作成功时,callback的err为空,result.value为读到的值
-* 当读操作失败时,callback的result为空
-* 客户端不认为读不到值时错误,因此当读不到值时,err仍为空,result.value为`Buffer('')`
+* 当读操作成功时,callback 的 err 为空,result.value 为读到的值
+* 当读操作失败时,callback 的 result 为空
+* 客户端不认为读不到值时错误,因此当读不到值时,err 仍为空,result.value 为 `Buffer('')`
 
 ## set
 写单行数据
@@ -112,8 +112,8 @@ client.close();
    }
  );
 ```
-* set操作的必填参数有表名,hashKey,sortKey,value和callback
-* 
ttl的含义为过期时间,单位为秒,默认ttl为0,则表示该数据不过期,若用户设置ttl为86400s,则表示该数据将在1天之后过期,用户在1天之后将无法读取到该数据
+* set 操作的必填参数有表名,hashKey,sortKey,value 和 callback
+* ttl 的含义为过期时间,单位为秒,默认 ttl 为 0,则表示该数据不过期,若用户设置 ttl 为 86400s,则表示该数据将在 1 
天之后过期,用户在 1 天之后将无法读取到该数据
 
 ## del
 删除单行数据
@@ -137,10 +137,10 @@ client.close();
    }
  );
 ```
-* del操作的必填参数有表名,hashKey,sortKey和callback
+* del 操作的必填参数有表名,hashKey,sortKey 和 callback
 
 ## multiGet
-读同一个hashKey下的多行数据
+读同一个 hashKey 下的多行数据
 ```
 /**
  * Multi Get
@@ -165,10 +165,10 @@ client.close();
    }
  );
 ```
-* multiGet操作的必填参数为表名,hashKey,sortKey数组和callback
-* 若sortKey数据为空数组,则表示期望获取该hashKey下的所有sortKey的值
-* maxFetchCount为最多获取数据的条数,默认为100
-* maxFetchSize为最大获取数据的大小,默认为1000000字节
+* multiGet 操作的必填参数为表名,hashKey,sortKey 数组和 callback
+* 若 sortKey 数据为空数组,则表示期望获取该 hashKey 下的所有 sortKey 的值
+* maxFetchCount 为最多获取数据的条数,默认为 100
+* maxFetchSize 为最大获取数据的大小,默认为 1000000 字节
 
 ## batchGet
 读取一批数据
@@ -194,14 +194,14 @@ client.close();
    }
  );
 ```
-* batchGet操作的必填参数为表名,hashKey数组,sortKey数组和callback
-* 与multiGet不同的是,batchGet支持读多个hashKey的值
-* batchGet将等待所有本次batch的所有get操作都返回结果后才返回
-* callback的err总是为null
-* 
callback的result是一个数组,result[i].error表示第i个get操作的出错情况,result[i].data表示第i个get操作的结果
+* batchGet 操作的必填参数为表名,hashKey 数组,sortKey 数组和 callback
+* 与 multiGet 不同的是,batchGet 支持读多个 hashKey 的值
+* batchGet 将等待所有本次 batch 的所有 get 操作都返回结果后才返回
+* callback 的 err 总是为 null
+* callback 的 result 是一个数组,result[i].error 表示第 i 个 get 操作的出错情况,result[i].data 
表示第 i 个 get 操作的结果
 
 ## multiSet
-写同一个hashKey下的多行数据
+写同一个 hashKey 下的多行数据
 ```
 /**
  * Multi Set
@@ -224,7 +224,7 @@ client.close();
    }
  );
 ```
-* multiSet操作的必填参数为表名,hashKey,sortKey-value对象数组和callback
+* multiSet 操作的必填参数为表名,hashKey,sortKey-value 对象数组和 callback
 
 ## batchSet
 写入一批数据
@@ -251,5 +251,5 @@ client.close();
    }
  );
 ```
-* batchSet操作的必填参数为表名,hashKey-sortKey-value对象数组和callback
-* callback的err总是为null,result[i].error表示第i个set操作的出错情况
+* batchSet 操作的必填参数为表名,hashKey-sortKey-value 对象数组和 callback
+* callback 的 err 总是为 null,result[i].error 表示第 i 个 set 操作的出错情况


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to