datafolder 1.0.52 → 1.0.53
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/ChangeLog.md +2 -0
- package/package.json +1 -1
- package/scripts/convertBinFiles.js +7 -7
- package/src/QyCache.d.ts +5 -2
- package/src/QyCache.js +90 -66
- package/src/QyDefaultOptions.js +4 -4
- package/src/QyFileLogger.d.ts +5 -4
- package/src/QyFileLogger.js +20 -17
- package/src/QyKVData.d.ts +1 -2
- package/src/QyKVData.js +77 -99
- package/src/QyKVDataUtils.d.ts +5 -0
- package/src/QyKVDataUtils.js +31 -0
- package/src/QyLogFileSaver.d.ts +1 -1
- package/src/QyLogFileSaver.js +7 -7
- package/src/QyLogFileSaver_Worker.d.ts +11 -5
- package/src/QyLogFileSaver_Worker.js +63 -12
- package/src/QyLogger.d.ts +12 -14
- package/src/QyLogger.js +129 -92
- package/src/QyMessager.d.ts +3 -1
- package/src/QyMessager.js +15 -12
- package/src/QyUtils.d.ts +1 -1
package/ChangeLog.md
CHANGED
package/package.json
CHANGED
|
@@ -4,8 +4,8 @@ import { iterPMBuffer, loadPrefixPMFile } from "../src/QySnapshots.js";
|
|
|
4
4
|
import { ensureDir, folderOrFileExists } from "../src/QyUtils.js";
|
|
5
5
|
import { logger } from "../src/QyLogger.js";
|
|
6
6
|
logger.level = "info";
|
|
7
|
-
|
|
8
|
-
async function
|
|
7
|
+
_run();
|
|
8
|
+
async function _loadPosMapFile(posMapFilePath) {
|
|
9
9
|
const buffer = await readFile(posMapFilePath);
|
|
10
10
|
const posMap = {};
|
|
11
11
|
for (const [key, vLStart, vLLength] of iterPMBuffer(buffer)) {
|
|
@@ -13,7 +13,7 @@ async function loadPosMapFile(posMapFilePath) {
|
|
|
13
13
|
}
|
|
14
14
|
return posMap;
|
|
15
15
|
}
|
|
16
|
-
async function
|
|
16
|
+
async function _run() {
|
|
17
17
|
const folderPath = process.argv[2];
|
|
18
18
|
let destFolderPath = process.argv[3];
|
|
19
19
|
if (!folderPath || !destFolderPath) {
|
|
@@ -22,15 +22,15 @@ async function run() {
|
|
|
22
22
|
else {
|
|
23
23
|
if (destFolderPath === "inplace")
|
|
24
24
|
destFolderPath = folderPath;
|
|
25
|
-
await
|
|
25
|
+
await _convertFolder(folderPath, destFolderPath);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
async function
|
|
28
|
+
async function _convertFolder(folder, destFolder) {
|
|
29
29
|
const promises = [];
|
|
30
30
|
for (const item of await readdir(folder, { withFileTypes: true })) {
|
|
31
31
|
const { name } = item;
|
|
32
32
|
if (item.isDirectory()) {
|
|
33
|
-
promises.push(
|
|
33
|
+
promises.push(_convertFolder(join(folder, name), join(destFolder, name)));
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
const match = /^[0-9]+_(pM|prefixPM)\.txt/.exec(name);
|
|
@@ -42,7 +42,7 @@ async function convertFolder(folder, destFolder) {
|
|
|
42
42
|
await ensureDir(destFolder);
|
|
43
43
|
console.log(`Converting ${filePath} -> ${destFilePath}`);
|
|
44
44
|
const map = match[1] === "pM"
|
|
45
|
-
? await
|
|
45
|
+
? await _loadPosMapFile(filePath)
|
|
46
46
|
: Object.fromEntries((await loadPrefixPMFile(filePath)).entries());
|
|
47
47
|
promises.push(writeFile(destFilePath, JSON.stringify(map, null, 2)));
|
|
48
48
|
}
|
package/src/QyCache.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import EventEmitter from "node:events";
|
|
2
2
|
import { QyDir } from "./QyDir.ts";
|
|
3
|
-
import {
|
|
3
|
+
import { QyLogFileSaver } from "./QyLogFileSaver.ts";
|
|
4
4
|
import { QyKVData } from "./QyKVData.ts";
|
|
5
5
|
import { QyEmbeddings } from "./QyEmbeddings.ts";
|
|
6
6
|
import type { QyFile } from "./QyFile.ts";
|
|
@@ -21,9 +21,12 @@ export declare class QyCache extends EventEmitter {
|
|
|
21
21
|
recycleRootDir: any;
|
|
22
22
|
hnswRootDir: any;
|
|
23
23
|
exclusiveFilePath: any;
|
|
24
|
+
isStopping: boolean;
|
|
25
|
+
unloadingMemory: boolean;
|
|
26
|
+
unloadInterval: any;
|
|
24
27
|
rpcFunMap: Map<string, Function>;
|
|
25
28
|
qyKVData: QyKVData;
|
|
26
|
-
|
|
29
|
+
qyLogFileSaver: QyLogFileSaver;
|
|
27
30
|
qyEmbeddings: QyEmbeddings;
|
|
28
31
|
constructor(rootFolder: string, options?: any, qyDB?: any);
|
|
29
32
|
start(): Promise<this>;
|
package/src/QyCache.js
CHANGED
|
@@ -9,27 +9,28 @@ import {
|
|
|
9
9
|
} from "./QyDir.js";
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
} from "./
|
|
12
|
+
QyLogFileSaver as l
|
|
13
|
+
} from "./QyLogFileSaver.js";
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
16
|
QyKVData as d
|
|
17
17
|
} from "./QyKVData.js";
|
|
18
18
|
|
|
19
19
|
import {
|
|
20
|
-
QyTriggerNode as
|
|
21
|
-
updateTriggerNodes as
|
|
20
|
+
QyTriggerNode as F,
|
|
21
|
+
updateTriggerNodes as s
|
|
22
22
|
} from "./QyTrigger.js";
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
-
isString as
|
|
25
|
+
isString as C,
|
|
26
26
|
lockExclusiveFilePath as q,
|
|
27
|
-
unlockExclusiveFilePath as
|
|
28
|
-
ensureDir as
|
|
29
|
-
HiddenDirName as
|
|
27
|
+
unlockExclusiveFilePath as a,
|
|
28
|
+
ensureDir as R,
|
|
29
|
+
HiddenDirName as g,
|
|
30
30
|
AboutFileName as r,
|
|
31
31
|
HiddenTopDirNameList as h,
|
|
32
|
-
HiddenDirNamePathList as b
|
|
32
|
+
HiddenDirNamePathList as b,
|
|
33
|
+
sleep as S
|
|
33
34
|
} from "./QyUtils.js";
|
|
34
35
|
|
|
35
36
|
import {
|
|
@@ -45,11 +46,11 @@ import {
|
|
|
45
46
|
} from "./QyDefaultOptions.js";
|
|
46
47
|
|
|
47
48
|
import {
|
|
48
|
-
QueryCounter as
|
|
49
|
+
QueryCounter as c
|
|
49
50
|
} from "./QyUnionNode.js";
|
|
50
51
|
|
|
51
52
|
import {
|
|
52
|
-
requireFromModCode as
|
|
53
|
+
requireFromModCode as D
|
|
53
54
|
} from "./QyMod.js";
|
|
54
55
|
|
|
55
56
|
import {
|
|
@@ -76,9 +77,12 @@ class t extends e {
|
|
|
76
77
|
recycleRootDir;
|
|
77
78
|
hnswRootDir;
|
|
78
79
|
exclusiveFilePath;
|
|
80
|
+
isStopping = !1;
|
|
81
|
+
unloadingMemory = !1;
|
|
82
|
+
unloadInterval;
|
|
79
83
|
rpcFunMap = new Map();
|
|
80
84
|
qyKVData;
|
|
81
|
-
|
|
85
|
+
qyLogFileSaver;
|
|
82
86
|
qyEmbeddings;
|
|
83
87
|
constructor(e, r, t) {
|
|
84
88
|
super(), this.rootFolder = e, r = this.options = {
|
|
@@ -87,78 +91,92 @@ class t extends e {
|
|
|
87
91
|
}, this.qyDB = t;
|
|
88
92
|
var i, t = f(e, "qykv"), o = (this.kvFolder = t, this.rpcFolder = f(e, "rpc"),
|
|
89
93
|
this.exclusiveFilePath = f(e, ".opened"), this.qyKVData = new d(t, r, this),
|
|
90
|
-
this.
|
|
91
|
-
this), t = o.rootDir = new n("", !0, void 0, o),
|
|
92
|
-
t._subdirMap = new Map([ [
|
|
94
|
+
this.qyLogFileSaver = new l(this, f(e, "qylog"), r), this.qyEmbeddings = new m(this, r),
|
|
95
|
+
this), t = o.rootDir = new n("", !0, void 0, o), a = o.hiddenDir = new n(g, !0, t);
|
|
96
|
+
t._subdirMap = new Map([ [ g, a ] ]), a._subdirMap = new Map();
|
|
93
97
|
for (i of h) {
|
|
94
|
-
var
|
|
95
|
-
|
|
98
|
+
var s = new n(i, !0, a);
|
|
99
|
+
a._subdirMap.set(i, s), o[i + "RootDir"] = s;
|
|
96
100
|
}
|
|
97
101
|
}
|
|
98
102
|
async start() {
|
|
103
|
+
this.isStopping = !1;
|
|
99
104
|
var {
|
|
100
105
|
rootFolder: e,
|
|
101
106
|
kvFolder: r,
|
|
102
107
|
options: t,
|
|
103
108
|
qyKVData: i,
|
|
104
|
-
|
|
105
|
-
exclusiveFilePath:
|
|
106
|
-
rootDir:
|
|
109
|
+
qyLogFileSaver: o,
|
|
110
|
+
exclusiveFilePath: a,
|
|
111
|
+
rootDir: s,
|
|
107
112
|
qyEmbeddings: n
|
|
108
113
|
} = this;
|
|
109
114
|
w.log("Starting at " + e);
|
|
110
115
|
try {
|
|
111
|
-
await
|
|
112
|
-
i.start();
|
|
116
|
+
await R(r), await Promise.all([ i.load(), q(a) ]), o.call_start(), w.setLogWorkerId(o.workerId),
|
|
117
|
+
i.start(), await n.start();
|
|
113
118
|
} catch (e) {
|
|
114
|
-
throw o.
|
|
119
|
+
throw o.call_stop(), n.stop(), e;
|
|
115
120
|
}
|
|
116
|
-
var
|
|
117
|
-
for (
|
|
121
|
+
var l, d = this, g = d.hiddenDir;
|
|
122
|
+
for (l of b) d[l.at(-1) + "RootDir"] = g.searchOrCreateSubdir(l);
|
|
118
123
|
t.preloadFoldersAtStart && !function e(r) {
|
|
119
124
|
let {
|
|
120
125
|
subdirList: t,
|
|
121
126
|
fileMap: i
|
|
122
127
|
} = r;
|
|
123
128
|
for (var o of t) e(o);
|
|
124
|
-
}(
|
|
129
|
+
}(s);
|
|
125
130
|
var h = this, {
|
|
126
131
|
rootDir: r,
|
|
127
|
-
triggerRootDir:
|
|
132
|
+
triggerRootDir: a
|
|
128
133
|
} = h;
|
|
129
|
-
r.triggerNodes = [ new
|
|
130
|
-
for (u of
|
|
134
|
+
r.triggerNodes = [ new F() ];
|
|
135
|
+
for (u of a.fileList) {
|
|
131
136
|
var {
|
|
132
137
|
name: u,
|
|
133
138
|
fileContent: p
|
|
134
|
-
} = u, [ p,
|
|
135
|
-
h.insertTriggerToTree(u, p,
|
|
139
|
+
} = u, [ p, c, D ] = p;
|
|
140
|
+
h.insertTriggerToTree(u, p, c, D);
|
|
136
141
|
}
|
|
137
142
|
var m = this;
|
|
138
143
|
for (y of m.rpcRootDir.fileList) {
|
|
139
144
|
var {
|
|
140
145
|
name: y,
|
|
141
|
-
fileContent:
|
|
146
|
+
fileContent: v
|
|
142
147
|
} = y;
|
|
143
|
-
|
|
148
|
+
C(v) && m.insertRpc(y, v);
|
|
144
149
|
}
|
|
145
|
-
return t.dumpStructureAtStart && await x(f(e, "qystruct"),
|
|
146
|
-
this
|
|
150
|
+
return t.dumpStructureAtStart && await x(f(e, "qystruct"), s), w.log("Started."),
|
|
151
|
+
this.unloadInterval = setInterval(() => (async t => {
|
|
152
|
+
if (!t.unloadingMemory) {
|
|
153
|
+
t.unloadingMemory = !0;
|
|
154
|
+
var i, o = t.options, a = o.maxFileCountToUnload, o = t.rootDir;
|
|
155
|
+
let e = I(t, o), r = e;
|
|
156
|
+
for (i of o.allLoadedSubdirs()) {
|
|
157
|
+
if (e > a && (r += e, e = 0, await S(0), t.isStopping)) break;
|
|
158
|
+
e += I(i, t.qyKVData.snapshotMaxChangeId);
|
|
159
|
+
}
|
|
160
|
+
r += e, global.gc && global.gc(), t.unloadingMemory = !1;
|
|
161
|
+
}
|
|
162
|
+
})(this), t.unloadMemInterval), this;
|
|
147
163
|
}
|
|
148
164
|
async stop() {
|
|
149
|
-
w.log("Stopping...");
|
|
165
|
+
this.isStopping = !0, w.log("Stopping...");
|
|
150
166
|
var {
|
|
151
167
|
qyKVData: e,
|
|
152
168
|
qyEmbeddings: r,
|
|
153
|
-
|
|
154
|
-
exclusiveFilePath: i
|
|
169
|
+
qyLogFileSaver: t,
|
|
170
|
+
exclusiveFilePath: i,
|
|
171
|
+
unloadInterval: o
|
|
155
172
|
} = this;
|
|
156
|
-
return await e.stop(), await r.stop(), w.log("
|
|
157
|
-
|
|
158
|
-
this.
|
|
159
|
-
this.
|
|
160
|
-
this.
|
|
161
|
-
this.
|
|
173
|
+
return clearInterval(o), await e.stop(), await r.stop(), w.log("qyLogFileSaver stopped."),
|
|
174
|
+
await t.call_stop(), a(i), this.rootDir = void 0, this.hiddenDir = void 0,
|
|
175
|
+
this.indexRootDir = void 0, this.triggerRootDir = void 0, this.rpcRootDir = void 0,
|
|
176
|
+
this.infoRootDir = void 0, this.embeddingRootDir = void 0, this.recycleRootDir = void 0,
|
|
177
|
+
this.hnswRootDir = void 0, this.qyKVData = void 0, this.rpcFunMap.clear(),
|
|
178
|
+
this.qyDB = void 0, this.qyLogFileSaver = void 0, this.qyEmbeddings = void 0,
|
|
179
|
+
this;
|
|
162
180
|
}
|
|
163
181
|
increaseChangeId() {
|
|
164
182
|
return this.qyKVData.increaseChangeId();
|
|
@@ -174,28 +192,28 @@ class t extends e {
|
|
|
174
192
|
}
|
|
175
193
|
save(e, r, t, i, o) {
|
|
176
194
|
var {
|
|
177
|
-
qyKVData:
|
|
178
|
-
|
|
195
|
+
qyKVData: a,
|
|
196
|
+
qyLogFileSaver: s
|
|
179
197
|
} = this;
|
|
180
|
-
return t &&
|
|
198
|
+
return t && s.cast_save(t), a.save(e, r, i, o);
|
|
181
199
|
}
|
|
182
200
|
getFile(e, r = this.rootDir) {
|
|
183
|
-
return e.isFile ? e :
|
|
201
|
+
return e.isFile ? e : C(e) ? r.getFile(e) : r.searchFile(e);
|
|
184
202
|
}
|
|
185
203
|
getOrCreateFile(e, r = this.rootDir) {
|
|
186
|
-
return e.isFile ? e :
|
|
204
|
+
return e.isFile ? e : C(e) ? r.getOrCreateFile(e) : r.searchOrCreateFile(e);
|
|
187
205
|
}
|
|
188
206
|
getDir(e, r = this.rootDir) {
|
|
189
|
-
return e.isDir ? e :
|
|
207
|
+
return e.isDir ? e : C(e) ? r.getSubdir(e) : r.searchSubdir(e);
|
|
190
208
|
}
|
|
191
209
|
getOrCreateDir(e, r = this.rootDir) {
|
|
192
|
-
return e.isDir ? e :
|
|
210
|
+
return e.isDir ? e : C(e) ? r.getOrCreateSubdir(e) : r.searchOrCreateSubdir(e);
|
|
193
211
|
}
|
|
194
212
|
getIndexDir(e) {
|
|
195
|
-
return this.indexRootDir.searchSubdir(
|
|
213
|
+
return this.indexRootDir.searchSubdir(o(e.fullPathHash));
|
|
196
214
|
}
|
|
197
215
|
getOrCreateIndexDir(e) {
|
|
198
|
-
return this.indexRootDir.searchOrCreateSubdir(
|
|
216
|
+
return this.indexRootDir.searchOrCreateSubdir(o(e.fullPathHash));
|
|
199
217
|
}
|
|
200
218
|
getTriggerFile(e) {
|
|
201
219
|
return this.triggerRootDir.getFile(e);
|
|
@@ -247,32 +265,32 @@ class t extends e {
|
|
|
247
265
|
insertTriggerToTree(e, r, t, i) {
|
|
248
266
|
var {
|
|
249
267
|
rootDir: o,
|
|
250
|
-
qyDB:
|
|
251
|
-
} = this, i =
|
|
252
|
-
o.triggerNodes[0].insertTrigger(e, r, t, i),
|
|
268
|
+
qyDB: a
|
|
269
|
+
} = this, i = D("trigger", e, i, a);
|
|
270
|
+
o.triggerNodes[0].insertTrigger(e, r, t, i), s(o, r);
|
|
253
271
|
}
|
|
254
272
|
removeTriggerFromTree(e, r) {
|
|
255
273
|
var t = this.rootDir;
|
|
256
|
-
t.triggerNodes[0].removeTrigger(e, r) &&
|
|
274
|
+
t.triggerNodes[0].removeTrigger(e, r) && s(t, r);
|
|
257
275
|
}
|
|
258
276
|
insertRpc(e, r) {
|
|
259
277
|
var {
|
|
260
278
|
rpcFunMap: t,
|
|
261
279
|
qyDB: i
|
|
262
|
-
} = this, r =
|
|
280
|
+
} = this, r = D("rpc", e, r, i);
|
|
263
281
|
r && t?.set(e, r);
|
|
264
282
|
}
|
|
265
283
|
removeRpc(e) {
|
|
266
284
|
this.rpcFunMap.delete(e);
|
|
267
285
|
}
|
|
268
286
|
queryFiles(e, r, t, i, o = this.rootDir) {
|
|
269
|
-
var
|
|
270
|
-
return y(e, r,
|
|
287
|
+
var a = [], t = (C(r) && !t && (t = 1), new c(t, i)), i = this.options.queryAutoIndex;
|
|
288
|
+
return y(e, r, a, t, o, i), a;
|
|
271
289
|
}
|
|
272
290
|
queryFilesMulti(e, r, t, i = this.rootDir) {
|
|
273
|
-
var o,
|
|
274
|
-
for ([ o,
|
|
275
|
-
return
|
|
291
|
+
var o, a, s = [], n = new c(r, t), l = this.options.queryAutoIndex;
|
|
292
|
+
for ([ o, a ] of e) y(o, a, s, n, i, l);
|
|
293
|
+
return s;
|
|
276
294
|
}
|
|
277
295
|
async callRpc(r, e, t) {
|
|
278
296
|
var i, o = this.rpcFunMap.get(r);
|
|
@@ -301,12 +319,18 @@ function i(e) {
|
|
|
301
319
|
return [ e.substring(0, 2), e ];
|
|
302
320
|
}
|
|
303
321
|
|
|
304
|
-
function
|
|
322
|
+
function o(e) {
|
|
305
323
|
return [ e[0], e ];
|
|
306
324
|
}
|
|
307
325
|
|
|
308
|
-
function y(e, r, t, i, o,
|
|
309
|
-
void 0 !== r && u(e, o,
|
|
326
|
+
function y(e, r, t, i, o, a) {
|
|
327
|
+
void 0 !== r && u(e, o, a, r, t, i);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function I(e, r) {
|
|
331
|
+
let t = 0;
|
|
332
|
+
if (e.fileMapLoaded) for (var i of e.fileList) ++t, i.cChangeId <= r && (i.visited ? i.visited = !1 : i.unloadFileContent());
|
|
333
|
+
return t;
|
|
310
334
|
}
|
|
311
335
|
|
|
312
336
|
export {
|
package/src/QyDefaultOptions.js
CHANGED
|
@@ -18,16 +18,16 @@ let t = {
|
|
|
18
18
|
snapshotMaxChangeCount: 1e6,
|
|
19
19
|
compactSnapshotsInterval: 6e4,
|
|
20
20
|
bgLoadPosMaps: !0,
|
|
21
|
-
unloadMemInterval: 12e4,
|
|
22
|
-
maxFileCountToUnload: 1e5,
|
|
23
21
|
compactAtStart: !0
|
|
24
22
|
},
|
|
25
23
|
QyCache: {
|
|
26
24
|
dumpStructureAtStart: !1,
|
|
27
25
|
queryAutoIndex: !0,
|
|
28
|
-
preloadFoldersAtStart: !1
|
|
26
|
+
preloadFoldersAtStart: !1,
|
|
27
|
+
unloadMemInterval: 12e4,
|
|
28
|
+
maxFileCountToUnload: 1e5
|
|
29
29
|
},
|
|
30
|
-
|
|
30
|
+
QyLogFileSaver: {
|
|
31
31
|
clearLogAtStart: !1
|
|
32
32
|
},
|
|
33
33
|
QySaver: {
|
package/src/QyFileLogger.d.ts
CHANGED
|
@@ -2,15 +2,16 @@ import { QyOpRunner } from "./QyOpRunner.ts";
|
|
|
2
2
|
import { QyLogFileSaver } from "./QyLogFileSaver.ts";
|
|
3
3
|
export declare class QyFileLogger extends QyOpRunner {
|
|
4
4
|
logFileFolder: any;
|
|
5
|
-
|
|
5
|
+
_dateDirPath: any;
|
|
6
6
|
timeoutRef: any;
|
|
7
7
|
qyLogFileSaver: QyLogFileSaver;
|
|
8
8
|
constructor(logFileFolder: any, options: any);
|
|
9
9
|
save(data: any): void;
|
|
10
|
-
|
|
10
|
+
get dateDirPath(): any;
|
|
11
|
+
get workerId(): number | undefined;
|
|
11
12
|
_op_start(): Promise<void>;
|
|
12
13
|
switch(): this;
|
|
13
|
-
_op_startFileConsole(
|
|
14
|
+
_op_startFileConsole(_dateDirPath: any): Promise<void>;
|
|
14
15
|
_op_stop(): Promise<void>;
|
|
15
|
-
_op_switchFileConsole(
|
|
16
|
+
_op_switchFileConsole(_dateDirPath: any): Promise<void>;
|
|
16
17
|
}
|
package/src/QyFileLogger.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
join as
|
|
2
|
+
join as r
|
|
3
3
|
} from "node:path";
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -15,56 +15,59 @@ import {
|
|
|
15
15
|
} from "./QyOpRunner.js";
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
|
-
QyLogFileSaver as
|
|
18
|
+
QyLogFileSaver as o
|
|
19
19
|
} from "./QyLogFileSaver.js";
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
|
-
logger as
|
|
22
|
+
logger as s
|
|
23
23
|
} from "./QyLogger.js";
|
|
24
24
|
|
|
25
|
-
class
|
|
25
|
+
class a extends t {
|
|
26
26
|
logFileFolder;
|
|
27
|
-
|
|
27
|
+
_dateDirPath;
|
|
28
28
|
timeoutRef;
|
|
29
29
|
qyLogFileSaver;
|
|
30
30
|
constructor(t, e) {
|
|
31
31
|
(e = {
|
|
32
32
|
...i("QyFileLogger"),
|
|
33
33
|
...e
|
|
34
|
-
}).append = !e.clearLogAtStart, super(e), this.logFileFolder = t, this.qyLogFileSaver = new
|
|
34
|
+
}).append = !e.clearLogAtStart, super(e), this.logFileFolder = t, this.qyLogFileSaver = new o(this, e);
|
|
35
35
|
}
|
|
36
36
|
save(t) {
|
|
37
37
|
this.qyLogFileSaver.cast_save(t);
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
return this.
|
|
39
|
+
get dateDirPath() {
|
|
40
|
+
return this._dateDirPath;
|
|
41
|
+
}
|
|
42
|
+
get workerId() {
|
|
43
|
+
return this.qyLogFileSaver.workerId;
|
|
41
44
|
}
|
|
42
45
|
async _op_start() {
|
|
43
46
|
var t = new Date(), t = (this.timeoutRef = setTimeout(this.switch.bind(this), h(t)),
|
|
44
|
-
this.
|
|
45
|
-
this.qyLogFileSaver.call_start(
|
|
47
|
+
this._dateDirPath = l(this, t));
|
|
48
|
+
this.qyLogFileSaver.call_start(r(t, "change.txt")), await this.startFileConsole(t);
|
|
46
49
|
}
|
|
47
50
|
switch() {
|
|
48
51
|
var t = new Date(), t = (this.timeoutRef = setTimeout(this.switch.bind(this), h(t)),
|
|
49
52
|
l(this, t));
|
|
50
|
-
return this.
|
|
53
|
+
return this._dateDirPath !== t && (this._dateDirPath = t, this.qyLogFileSaver.cast_switch(r(t, "change.txt")),
|
|
51
54
|
this.switchFileConsole(t)), this;
|
|
52
55
|
}
|
|
53
56
|
async _op_startFileConsole(t) {
|
|
54
|
-
await e(t),
|
|
57
|
+
await e(t), s.setFileConsoleDateDirPath(t, this.options.clearLogAtStart);
|
|
55
58
|
}
|
|
56
59
|
async _op_stop() {
|
|
57
60
|
this.timeoutRef && (clearTimeout(this.timeoutRef), this.timeoutRef = void 0),
|
|
58
|
-
|
|
61
|
+
s.closeFileConsole(), await this.qyLogFileSaver.call_stop();
|
|
59
62
|
}
|
|
60
63
|
async _op_switchFileConsole(t) {
|
|
61
|
-
await e(t),
|
|
64
|
+
await e(t), s.setFileConsoleDateDirPath(t, this.options.clearLogAtStart);
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
function l(t, e) {
|
|
66
|
-
var i = e.getUTCFullYear(),
|
|
67
|
-
return
|
|
69
|
+
var i = e.getUTCFullYear(), o = e.getUTCMonth() + 1, s = e.getUTCDate(), e = e.getUTCHours();
|
|
70
|
+
return r(t.logFileFolder, i.toString(), n(o), n(s), n(e));
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
function n(t) {
|
|
@@ -76,5 +79,5 @@ function h(t) {
|
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
export {
|
|
79
|
-
|
|
82
|
+
a as QyFileLogger
|
|
80
83
|
};
|
package/src/QyKVData.d.ts
CHANGED
|
@@ -15,16 +15,15 @@ export declare class QyKVData {
|
|
|
15
15
|
loadedMaxAclNum: number;
|
|
16
16
|
emptySnapshotNumVerList: any[];
|
|
17
17
|
isStopping: boolean;
|
|
18
|
-
unloadingMemory: boolean;
|
|
19
18
|
keyValueMap: any;
|
|
20
19
|
compactInterval: any;
|
|
21
|
-
unloadInterval: any;
|
|
22
20
|
qySnapshots: QySnapshots | undefined;
|
|
23
21
|
qyKVDataSaver: QyKVDataSaver;
|
|
24
22
|
qySnapshotCompactor: QySnapshotCompactor;
|
|
25
23
|
qyKVDataCleaner: QyKVDataCleaner;
|
|
26
24
|
qyExpireMonitor: QyExpireMonitor;
|
|
27
25
|
constructor(kvFolder: any, options?: any, qyCache?: any);
|
|
26
|
+
get snapshotMaxChangeId(): number;
|
|
28
27
|
load(): Promise<void>;
|
|
29
28
|
start(): this;
|
|
30
29
|
stop(): Promise<void>;
|