dolphindb 2.0.525 → 2.0.526
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 +2 -1
- package/browser.js +22 -7
- package/browser.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.js +22 -7
- package/index.js.map +1 -1
- package/package.json +2 -2
package/browser.d.ts
CHANGED
|
@@ -383,7 +383,8 @@ export declare class DDB {
|
|
|
383
383
|
parse_object: boolean;
|
|
384
384
|
/** DdbMessage listeners */
|
|
385
385
|
listeners: DdbMessageListener[];
|
|
386
|
-
|
|
386
|
+
pconnect: Promise<void>;
|
|
387
|
+
presult: Promise<any>;
|
|
387
388
|
get connected(): boolean;
|
|
388
389
|
/**
|
|
389
390
|
Initialize an instance of DolphinDB Client using the WebSocket URL
|
package/browser.js
CHANGED
|
@@ -1914,7 +1914,8 @@ class DDB {
|
|
|
1914
1914
|
this.parse_object = true;
|
|
1915
1915
|
/** DdbMessage listeners */
|
|
1916
1916
|
this.listeners = [];
|
|
1917
|
-
this.
|
|
1917
|
+
this.pconnect = Promise.resolve();
|
|
1918
|
+
this.presult = Promise.resolve(null);
|
|
1918
1919
|
if (!url) {
|
|
1919
1920
|
const _url = new URL(location.href);
|
|
1920
1921
|
const hostname = _url.searchParams.get('hostname') || location.hostname;
|
|
@@ -2041,7 +2042,8 @@ class DDB {
|
|
|
2041
2042
|
if (this.connected)
|
|
2042
2043
|
this.websocket.close(1000);
|
|
2043
2044
|
this.on_message = () => { };
|
|
2044
|
-
this.
|
|
2045
|
+
this.presult = Promise.resolve(null);
|
|
2046
|
+
this.pconnect = Promise.resolve();
|
|
2045
2047
|
}
|
|
2046
2048
|
/** rpc through websocket (function/script/variable command)
|
|
2047
2049
|
- type: API 类型: 'script' | 'function' | 'variable'
|
|
@@ -2053,8 +2055,21 @@ class DDB {
|
|
|
2053
2055
|
为 false 时返回的 DdbObj 仅含有 buffer 和 le,不做解析,以便后续转发、序列化
|
|
2054
2056
|
*/
|
|
2055
2057
|
async rpc(type, { script, func, args = [], vars = [], urgent, listener, parse_object, }) {
|
|
2056
|
-
if (!this.websocket)
|
|
2057
|
-
|
|
2058
|
+
if (!this.websocket) {
|
|
2059
|
+
const ptail = this.pconnect;
|
|
2060
|
+
let resolve;
|
|
2061
|
+
this.pconnect = new Promise((_resolve, _reject) => {
|
|
2062
|
+
resolve = _resolve;
|
|
2063
|
+
});
|
|
2064
|
+
await ptail;
|
|
2065
|
+
try {
|
|
2066
|
+
if (!this.websocket)
|
|
2067
|
+
await this.connect();
|
|
2068
|
+
}
|
|
2069
|
+
finally {
|
|
2070
|
+
resolve();
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2058
2073
|
if (!this.connected)
|
|
2059
2074
|
throw new Error(`${this.url} is already disconnected`);
|
|
2060
2075
|
// this 上的当前配置需要在 message 到达后使用,先保存起来
|
|
@@ -2064,10 +2079,10 @@ class DDB {
|
|
|
2064
2079
|
// 违反世界观可能造成:
|
|
2065
2080
|
// 1. 并发多个请求只返回第一个结果(阻塞,需后续请求疏通)
|
|
2066
2081
|
// 2. windows 下 ddb server 返回多个相同的结果
|
|
2067
|
-
const ptail = this.
|
|
2082
|
+
const ptail = this.presult;
|
|
2068
2083
|
let resolve;
|
|
2069
2084
|
let reject;
|
|
2070
|
-
const
|
|
2085
|
+
const presult = this.presult = new Promise((_resolve, _reject) => {
|
|
2071
2086
|
resolve = _resolve;
|
|
2072
2087
|
reject = _reject;
|
|
2073
2088
|
});
|
|
@@ -2128,7 +2143,7 @@ class DDB {
|
|
|
2128
2143
|
command,
|
|
2129
2144
|
...args.map((arg) => arg.pack())
|
|
2130
2145
|
]));
|
|
2131
|
-
return
|
|
2146
|
+
return presult;
|
|
2132
2147
|
}
|
|
2133
2148
|
/** eval script through websocket (script command)
|
|
2134
2149
|
- script?: Script to execute
|