dolphindb 3.0.122 → 3.0.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser.d.ts +3 -5
- package/browser.js +61 -31
- package/browser.js.map +1 -1
- package/index.d.ts +3 -5
- package/index.js +61 -31
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -631,7 +631,6 @@ export interface DdbOptions {
|
|
|
631
631
|
export interface DdbCallOptions extends DdbEvalOptions {
|
|
632
632
|
node?: string;
|
|
633
633
|
nodes?: string[];
|
|
634
|
-
func_type?: DdbFunctionType;
|
|
635
634
|
add_node_alias?: boolean;
|
|
636
635
|
skip_connection_check?: boolean;
|
|
637
636
|
on_more_messages?: DdbRpcOptions['on_more_messages'];
|
|
@@ -686,6 +685,8 @@ export declare class DDB {
|
|
|
686
685
|
ppnode_run: Promise<DdbVoid>;
|
|
687
686
|
/** 首次定义 invoke 的 promise,保证并发调用 rpc 时只定义一次 invoke */
|
|
688
687
|
pinvoke: Promise<DdbVoid>;
|
|
688
|
+
/** 首次定义 jsrpc 的 promise,保证并发调用 rpc 时只定义一次 jsrpc */
|
|
689
|
+
pjsrpc: Promise<DdbVoid>;
|
|
689
690
|
get connected(): boolean;
|
|
690
691
|
/**
|
|
691
692
|
使用 WebSocket URL 初始化连接到 DolphinDB 的实例(不建立实际的网络连接)
|
|
@@ -790,8 +791,6 @@ export declare class DDB {
|
|
|
790
791
|
When the node alias is set, it is sent to the corresponding node in the cluster for execution (using the rpc method in DolphinDB)
|
|
791
792
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
792
793
|
When setting multiple node aliases, send them to the corresponding multiple nodes in the cluster for execution (using the pnodeRun method in DolphinDB)
|
|
793
|
-
- func_type?: 设置 node 参数时必传,需指定函数类型,其它情况下不传
|
|
794
|
-
It must be passed when setting the node parameter, the function type needs to be specified, and it is not passed in other cases
|
|
795
794
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
796
795
|
Select to pass when setting the nodes parameter, otherwise not pass
|
|
797
796
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage)
|
|
@@ -805,7 +804,7 @@ export declare class DDB {
|
|
|
805
804
|
将这个 flag 设为 true 跳过连接状态检查
|
|
806
805
|
(internal use) When await ddb.connect() establishes a connection for the first time, you cannot call await this.connect() again to ensure the connection status, which will lead to circular dependencies.
|
|
807
806
|
Set this flag to true to skip connection status checks */
|
|
808
|
-
call<TResult extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes,
|
|
807
|
+
call<TResult extends DdbObj>(func: string, args?: (DdbObj | string | boolean)[], { urgent, node, nodes, add_node_alias, listener, parse_object, skip_connection_check, on_more_messages }?: DdbCallOptions): Promise<TResult>;
|
|
809
808
|
/** 调用 dolphindb 函数,传入 js 原生数组作为参数,返回 js 原生对象或值(调用 DdbObj.data() 后的结果)
|
|
810
809
|
- func: 函数名
|
|
811
810
|
- args?: `[ ]` 调用参数,可以是 js 原生数组,参数在中间且想用 server 函数的默认参数值时可以传 null 占位
|
|
@@ -813,7 +812,6 @@ export declare class DDB {
|
|
|
813
812
|
- urgent?: 紧急 flag。使用 urgent worker 执行,防止被其它作业阻塞
|
|
814
813
|
- node?: 设置结点 alias 时发送到集群中对应的结点执行 (使用 DolphinDB 中的 rpc 方法)
|
|
815
814
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
816
|
-
- func_type?: 设置 node 参数且参数数组为空时必传,需指定函数类型,其它情况下不传
|
|
817
815
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
818
816
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage) */
|
|
819
817
|
invoke<TResult = any>(func: string, args?: any[], options?: DdbInvokeOptions): Promise<TResult>;
|
package/index.js
CHANGED
|
@@ -2761,6 +2761,8 @@ export class DDB {
|
|
|
2761
2761
|
ppnode_run;
|
|
2762
2762
|
/** 首次定义 invoke 的 promise,保证并发调用 rpc 时只定义一次 invoke */
|
|
2763
2763
|
pinvoke;
|
|
2764
|
+
/** 首次定义 jsrpc 的 promise,保证并发调用 rpc 时只定义一次 jsrpc */
|
|
2765
|
+
pjsrpc;
|
|
2764
2766
|
get connected() {
|
|
2765
2767
|
return !this.error && this.lwebsocket.resource?.readyState === WebSocketOpen;
|
|
2766
2768
|
}
|
|
@@ -3151,8 +3153,6 @@ export class DDB {
|
|
|
3151
3153
|
When the node alias is set, it is sent to the corresponding node in the cluster for execution (using the rpc method in DolphinDB)
|
|
3152
3154
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
3153
3155
|
When setting multiple node aliases, send them to the corresponding multiple nodes in the cluster for execution (using the pnodeRun method in DolphinDB)
|
|
3154
|
-
- func_type?: 设置 node 参数时必传,需指定函数类型,其它情况下不传
|
|
3155
|
-
It must be passed when setting the node parameter, the function type needs to be specified, and it is not passed in other cases
|
|
3156
3156
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
3157
3157
|
Select to pass when setting the nodes parameter, otherwise not pass
|
|
3158
3158
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage)
|
|
@@ -3166,18 +3166,41 @@ export class DDB {
|
|
|
3166
3166
|
将这个 flag 设为 true 跳过连接状态检查
|
|
3167
3167
|
(internal use) When await ddb.connect() establishes a connection for the first time, you cannot call await this.connect() again to ensure the connection status, which will lead to circular dependencies.
|
|
3168
3168
|
Set this flag to true to skip connection status checks */
|
|
3169
|
-
async call(func, args = [], { urgent, node, nodes,
|
|
3169
|
+
async call(func, args = [], { urgent, node, nodes, add_node_alias, listener, parse_object, skip_connection_check, on_more_messages } = {}) {
|
|
3170
|
+
let func_ = func;
|
|
3171
|
+
let args_ = args;
|
|
3170
3172
|
if (node) {
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
+
try {
|
|
3174
|
+
await (this.pjsrpc ??= this.eval(this.python ?
|
|
3175
|
+
'\n' +
|
|
3176
|
+
'def jsrpc (node, func_name, args):\n' +
|
|
3177
|
+
' args_ = args\n' +
|
|
3178
|
+
' if func_name == "invoke":\n' +
|
|
3179
|
+
' args_[0] = funcByName(args[0])\n' +
|
|
3180
|
+
' return rpc(node, unifiedCall, funcByName(func_name), args_)\n'
|
|
3181
|
+
:
|
|
3182
|
+
'\n' +
|
|
3183
|
+
'def jsrpc (node, func_name, args) {\n' +
|
|
3184
|
+
' args_ = args\n' +
|
|
3185
|
+
' if (func_name == "invoke")\n' +
|
|
3186
|
+
' args_[0] = funcByName(args[0])\n' +
|
|
3187
|
+
' return rpc(node, unifiedCall, funcByName(func_name), args_)\n' +
|
|
3188
|
+
'}\n', { urgent: true }));
|
|
3189
|
+
}
|
|
3190
|
+
catch (error) {
|
|
3191
|
+
this.pjsrpc = undefined;
|
|
3192
|
+
throw error;
|
|
3193
|
+
}
|
|
3194
|
+
func_ = 'jsrpc';
|
|
3195
|
+
args_ = [
|
|
3173
3196
|
node,
|
|
3174
|
-
|
|
3175
|
-
|
|
3197
|
+
func,
|
|
3198
|
+
new DdbVectorAny(args)
|
|
3176
3199
|
];
|
|
3177
|
-
func = 'rpc';
|
|
3178
3200
|
}
|
|
3179
3201
|
if (nodes) {
|
|
3180
|
-
|
|
3202
|
+
func_ = 'pnode_run';
|
|
3203
|
+
args_ = [
|
|
3181
3204
|
new DdbVectorString(nodes),
|
|
3182
3205
|
func,
|
|
3183
3206
|
new DdbVectorAny(args),
|
|
@@ -3189,11 +3212,10 @@ export class DDB {
|
|
|
3189
3212
|
return [];
|
|
3190
3213
|
})()
|
|
3191
3214
|
];
|
|
3192
|
-
func = 'pnode_run';
|
|
3193
3215
|
}
|
|
3194
3216
|
return this.rpc('function', {
|
|
3195
|
-
func,
|
|
3196
|
-
args,
|
|
3217
|
+
func: func_,
|
|
3218
|
+
args: args_,
|
|
3197
3219
|
urgent,
|
|
3198
3220
|
listener,
|
|
3199
3221
|
parse_object,
|
|
@@ -3208,25 +3230,37 @@ export class DDB {
|
|
|
3208
3230
|
- urgent?: 紧急 flag。使用 urgent worker 执行,防止被其它作业阻塞
|
|
3209
3231
|
- node?: 设置结点 alias 时发送到集群中对应的结点执行 (使用 DolphinDB 中的 rpc 方法)
|
|
3210
3232
|
- nodes?: 设置多个结点 alias 时发送到集群中对应的多个结点执行 (使用 DolphinDB 中的 pnodeRun 方法)
|
|
3211
|
-
- func_type?: 设置 node 参数且参数数组为空时必传,需指定函数类型,其它情况下不传
|
|
3212
3233
|
- add_node_alias?: 设置 nodes 参数时选传,其它情况不传
|
|
3213
3234
|
- listener?: 处理本次 rpc 期间的消息 (DdbMessage) */
|
|
3214
3235
|
async invoke(func, args, options) {
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
'def invoke (func_name, args_json):\n' +
|
|
3218
|
-
' args = fromStdJson(args_json)\n' +
|
|
3219
|
-
' if type(args) != ANY:\n' +
|
|
3220
|
-
' args = cast(args, ANY)\n' +
|
|
3221
|
-
' return unifiedCall(funcByName(func_name), args)\n'
|
|
3222
|
-
:
|
|
3236
|
+
try {
|
|
3237
|
+
await (this.pinvoke ??= this.eval(this.python ?
|
|
3223
3238
|
'\n' +
|
|
3224
|
-
'def invoke (
|
|
3239
|
+
'def invoke (func, args_json):\n' +
|
|
3225
3240
|
' args = fromStdJson(args_json)\n' +
|
|
3226
|
-
'
|
|
3241
|
+
' func_ = func\n' +
|
|
3242
|
+
' if type(func) == STRING:\n' +
|
|
3243
|
+
' func_ = funcByName(func)\n' +
|
|
3244
|
+
' if type(args) != ANY:\n' +
|
|
3227
3245
|
' args = cast(args, ANY)\n' +
|
|
3228
|
-
' return unifiedCall(
|
|
3229
|
-
|
|
3246
|
+
' return unifiedCall(func_, args)\n'
|
|
3247
|
+
:
|
|
3248
|
+
'\n' +
|
|
3249
|
+
'def invoke (func, args_json) {\n' +
|
|
3250
|
+
' args = fromStdJson(args_json)\n' +
|
|
3251
|
+
' func_ = func\n' +
|
|
3252
|
+
' if (type(func) == STRING)\n' +
|
|
3253
|
+
' func_ = funcByName(func)\n' +
|
|
3254
|
+
' if (type(args) != ANY)\n' +
|
|
3255
|
+
' args = cast(args, ANY)\n' +
|
|
3256
|
+
' return unifiedCall(func_, args)\n' +
|
|
3257
|
+
'}\n', { urgent: true }));
|
|
3258
|
+
}
|
|
3259
|
+
catch (error) {
|
|
3260
|
+
// invoke 没有正确执行时,重新将 pinvoke 赋值为 undefined
|
|
3261
|
+
this.pinvoke = undefined;
|
|
3262
|
+
throw error;
|
|
3263
|
+
}
|
|
3230
3264
|
// 检查 args 是否全部为简单参数,是则直接调用 call,避免 invoke 间接调用
|
|
3231
3265
|
// 逻辑类似 DdbObj.to_ddbobjs, 需要同步修改
|
|
3232
3266
|
let simple = true;
|
|
@@ -3243,12 +3277,8 @@ export class DDB {
|
|
|
3243
3277
|
break;
|
|
3244
3278
|
}
|
|
3245
3279
|
}
|
|
3246
|
-
if (!simple)
|
|
3247
|
-
|
|
3248
|
-
throw new Error(t('调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象'));
|
|
3249
|
-
if (options?.node)
|
|
3250
|
-
options.func_type = DdbFunctionType.UserDefinedFunc;
|
|
3251
|
-
}
|
|
3280
|
+
if (!simple && has_ddbobj)
|
|
3281
|
+
throw new Error(t('调用 ddb.invoke 的参数中不能同时有 DdbObj 与复杂 js 原生对象'));
|
|
3252
3282
|
const result = simple
|
|
3253
3283
|
? await this.call(func, args, options)
|
|
3254
3284
|
: await this.call('invoke', [func, JSON.stringify(args)], options);
|