@nxtedition/lib 20.0.9 → 20.1.1
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/app.js +4 -2
- package/package.json +1 -1
- package/sequence.js +28 -1
package/app.js
CHANGED
|
@@ -282,7 +282,7 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
282
282
|
|
|
283
283
|
process.send?.({ type: 'nxt:lag', id, currentLag })
|
|
284
284
|
|
|
285
|
-
let appLag = currentLag$.value
|
|
285
|
+
let appLag = currentLag$.value ?? 0
|
|
286
286
|
for (const lag of lagMap.values()) {
|
|
287
287
|
appLag = Math.max(appLag, lag ?? 0)
|
|
288
288
|
}
|
|
@@ -440,9 +440,11 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
440
440
|
stats$ = rxjs.timer(0, 10e3).pipe(rx.map(() => ({})))
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
+
const startTime = Date.now()
|
|
443
444
|
stats$ = stats$.pipe(
|
|
444
445
|
rx.map((x) => ({
|
|
445
446
|
...x,
|
|
447
|
+
uptime: Date.now() - startTime,
|
|
446
448
|
timestamp: Date.now(),
|
|
447
449
|
})),
|
|
448
450
|
rx.auditTime(1e3),
|
|
@@ -532,7 +534,7 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
532
534
|
id: 'app:toobusy_lag',
|
|
533
535
|
level: lag > 1e3 ? 50 : lag > toobusy.maxLAge ? 40 : 30,
|
|
534
536
|
code: 'NXT_LAG',
|
|
535
|
-
msg: `Lag: ${lag
|
|
537
|
+
msg: `Lag: ${lag?.toFixed(2) ?? '?'} ms`,
|
|
536
538
|
},
|
|
537
539
|
]),
|
|
538
540
|
) ?? rxjs.of([]),
|
package/package.json
CHANGED
package/sequence.js
CHANGED
|
@@ -24,9 +24,36 @@ export class Sequence {
|
|
|
24
24
|
#parts = []
|
|
25
25
|
#identity
|
|
26
26
|
|
|
27
|
+
// TODO (perf): Optimize
|
|
28
|
+
static compare(a, b) {
|
|
29
|
+
if (!a && !b) {
|
|
30
|
+
return 0
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (a && !b) {
|
|
34
|
+
return 1
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!a && b) {
|
|
38
|
+
return -1
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (typeof a === 'string') {
|
|
42
|
+
a = new Sequence(a)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (typeof b === 'string') {
|
|
46
|
+
b = new Sequence(b)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return a.compare(b)
|
|
50
|
+
}
|
|
51
|
+
|
|
27
52
|
constructor(value, identity) {
|
|
28
53
|
try {
|
|
29
|
-
if (
|
|
54
|
+
if (!value) {
|
|
55
|
+
this.#value = '0'
|
|
56
|
+
} else if (Array.isArray(value)) {
|
|
30
57
|
for (const part of value) {
|
|
31
58
|
if (typeof part === 'string') {
|
|
32
59
|
const [sequenceStr, id] = part.split(ID_SEP)
|