@nxtedition/lib 15.0.23 → 15.0.25
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 +75 -84
- package/http.js +2 -2
- package/package.json +1 -1
- package/stream.js +3 -1
package/app.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const os = require('node:os')
|
|
2
2
|
const net = require('node:net')
|
|
3
|
-
const assert = require('node:assert')
|
|
4
3
|
const stream = require('node:stream')
|
|
5
4
|
const { Buffer } = require('node:buffer')
|
|
6
5
|
const { getDockerSecretsSync } = require('./docker-secrets')
|
|
@@ -408,7 +407,6 @@ module.exports = function (appConfig, onTerminate) {
|
|
|
408
407
|
if (appConfig.status) {
|
|
409
408
|
const rxjs = require('rxjs')
|
|
410
409
|
const rx = require('rxjs/operators')
|
|
411
|
-
const undici = require('undici')
|
|
412
410
|
const fp = require('lodash/fp')
|
|
413
411
|
const hashString = require('./hash')
|
|
414
412
|
|
|
@@ -489,89 +487,82 @@ module.exports = function (appConfig, onTerminate) {
|
|
|
489
487
|
)
|
|
490
488
|
: rxjs.of({}),
|
|
491
489
|
ds
|
|
492
|
-
?
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
id: 'app:
|
|
506
|
-
level: 40,
|
|
507
|
-
code: 'NXT_DEEPSTREAM_RECORDS_RECORDS',
|
|
508
|
-
msg: 'ds: ' + ds.stats.record.records + ' records',
|
|
509
|
-
})
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
if (ds.stats.record.pruning > 100e3) {
|
|
513
|
-
messages.push({
|
|
514
|
-
id: 'app:ds_record_pruning',
|
|
515
|
-
level: 40,
|
|
516
|
-
code: 'NXT_DEEPSTREAM_RECORDS_PRUNING',
|
|
517
|
-
msg: 'ds: ' + ds.stats.record.pruning + ' pruning',
|
|
518
|
-
})
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
if (ds.stats.record.pending > 10e3) {
|
|
522
|
-
messages.push({
|
|
523
|
-
id: 'app:ds_record_pending',
|
|
524
|
-
level: 40,
|
|
525
|
-
code: 'NXT_DEEPSTREAM_RECORDS_PENDING',
|
|
526
|
-
msg: 'ds: ' + ds.stats.record.pending + ' pending',
|
|
527
|
-
})
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
if (ds.stats.record.updating > 10e3) {
|
|
531
|
-
messages.push({
|
|
532
|
-
id: 'app:ds_record_updating',
|
|
533
|
-
level: 40,
|
|
534
|
-
code: 'NXT_DEEPSTREAM_RECORDS_UPDATING',
|
|
535
|
-
msg: 'ds: ' + ds.stats.record.updating + ' updating',
|
|
536
|
-
})
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
if (ds.stats.record.patching > 10e3) {
|
|
540
|
-
messages.push({
|
|
541
|
-
id: 'app:ds_record_patching',
|
|
542
|
-
level: 40,
|
|
543
|
-
code: 'NXT_DEEPSTREAM_RECORDS_PATCHING',
|
|
544
|
-
msg: 'ds: ' + ds.stats.record.patching + ' patching',
|
|
545
|
-
})
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
try {
|
|
549
|
-
const { body, statusCode } = await client.request({
|
|
550
|
-
method: 'GET',
|
|
551
|
-
path: '/healthcheck',
|
|
552
|
-
})
|
|
553
|
-
await body.dump()
|
|
554
|
-
assert(statusCode >= 200 && statusCode < 300)
|
|
555
|
-
} catch (err) {
|
|
556
|
-
messages.push({
|
|
557
|
-
id: 'app:ds_http_connection',
|
|
490
|
+
? rxjs.fromEvent(ds, 'connectionStateChanged').pipe(
|
|
491
|
+
rxjs.map((connectionState) =>
|
|
492
|
+
connectionState === 'OPEN'
|
|
493
|
+
? [
|
|
494
|
+
{
|
|
495
|
+
id: 'app:ds_connection_state',
|
|
496
|
+
level: 30,
|
|
497
|
+
msg: 'ds: connected',
|
|
498
|
+
data: { connectionState },
|
|
499
|
+
},
|
|
500
|
+
]
|
|
501
|
+
: [
|
|
502
|
+
{
|
|
503
|
+
id: 'app:ds_connection_state',
|
|
558
504
|
level: 40,
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
505
|
+
msg: 'ds: connecting',
|
|
506
|
+
data: { connectionState },
|
|
507
|
+
},
|
|
508
|
+
],
|
|
509
|
+
),
|
|
510
|
+
)
|
|
511
|
+
: rxjs.of([]),
|
|
512
|
+
ds
|
|
513
|
+
? rxjs.timer(0, 10e3).pipe(
|
|
514
|
+
rx.exhaustMap(async () => {
|
|
515
|
+
const messages = []
|
|
516
|
+
|
|
517
|
+
if (ds.stats.record.records > 100e3) {
|
|
518
|
+
messages.push({
|
|
519
|
+
id: 'app:ds_record_records',
|
|
520
|
+
level: 40,
|
|
521
|
+
code: 'NXT_DEEPSTREAM_RECORDS_RECORDS',
|
|
522
|
+
msg: 'ds: ' + ds.stats.record.records + ' records',
|
|
523
|
+
})
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (ds.stats.record.pruning > 100e3) {
|
|
527
|
+
messages.push({
|
|
528
|
+
id: 'app:ds_record_pruning',
|
|
529
|
+
level: 40,
|
|
530
|
+
code: 'NXT_DEEPSTREAM_RECORDS_PRUNING',
|
|
531
|
+
msg: 'ds: ' + ds.stats.record.pruning + ' pruning',
|
|
532
|
+
})
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
if (ds.stats.record.pending > 10e3) {
|
|
536
|
+
messages.push({
|
|
537
|
+
id: 'app:ds_record_pending',
|
|
538
|
+
level: 40,
|
|
539
|
+
code: 'NXT_DEEPSTREAM_RECORDS_PENDING',
|
|
540
|
+
msg: 'ds: ' + ds.stats.record.pending + ' pending',
|
|
541
|
+
})
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
if (ds.stats.record.updating > 10e3) {
|
|
545
|
+
messages.push({
|
|
546
|
+
id: 'app:ds_record_updating',
|
|
547
|
+
level: 40,
|
|
548
|
+
code: 'NXT_DEEPSTREAM_RECORDS_UPDATING',
|
|
549
|
+
msg: 'ds: ' + ds.stats.record.updating + ' updating',
|
|
550
|
+
})
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (ds.stats.record.patching > 10e3) {
|
|
554
|
+
messages.push({
|
|
555
|
+
id: 'app:ds_record_patching',
|
|
556
|
+
level: 40,
|
|
557
|
+
code: 'NXT_DEEPSTREAM_RECORDS_PATCHING',
|
|
558
|
+
msg: 'ds: ' + ds.stats.record.patching + ' patching',
|
|
559
|
+
})
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
return messages
|
|
563
|
+
}),
|
|
564
|
+
)
|
|
565
|
+
: rxjs.of([]),
|
|
575
566
|
rxjs.timer(0, 10e3),
|
|
576
567
|
].filter(Boolean),
|
|
577
568
|
)
|
package/http.js
CHANGED
|
@@ -331,11 +331,11 @@ module.exports.delay = defaultDelay
|
|
|
331
331
|
module.exports.isConnectionError = isConnectionError
|
|
332
332
|
|
|
333
333
|
module.exports.retry = async function _retry(fn, options) {
|
|
334
|
-
const { maxRetries = 8, count = maxRetries, delay = defaultDelay } = options ?? {}
|
|
334
|
+
const { maxRetries = 8, count = maxRetries, delay = defaultDelay, signal } = options ?? {}
|
|
335
335
|
|
|
336
336
|
for (let retryCount = 0; true; ++retryCount) {
|
|
337
337
|
try {
|
|
338
|
-
return await fn()
|
|
338
|
+
return await fn({ retryCount, signal })
|
|
339
339
|
} catch (err) {
|
|
340
340
|
if (retryCount >= count) {
|
|
341
341
|
throw err
|
package/package.json
CHANGED
package/stream.js
CHANGED
|
@@ -22,7 +22,9 @@ function readableStreamLength(stream) {
|
|
|
22
22
|
return null
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
stream.read
|
|
25
|
+
if (stream.read) {
|
|
26
|
+
stream.read(0)
|
|
27
|
+
}
|
|
26
28
|
|
|
27
29
|
const state = stream._readableState
|
|
28
30
|
return state && state.ended === true && Number.isFinite(state.length) ? state.length : null
|