@usherlabs/cex-broker 0.2.26 → 0.2.27
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/dist/commands/cli.js
CHANGED
|
@@ -315929,6 +315929,7 @@ var DEFAULT_MAX_QUEUE_SIZE = 1e4;
|
|
|
315929
315929
|
var DEFAULT_BATCH_SIZE = 10;
|
|
315930
315930
|
var DEFAULT_FLUSH_INTERVAL_MS = 1000;
|
|
315931
315931
|
var DEFAULT_FORWARDER_TIMEOUT_MS = 3000;
|
|
315932
|
+
var SHED_WARN_INTERVAL_MS = 60000;
|
|
315932
315933
|
var DEFAULT_ARCHIVE_FORWARDER_PATH = "/archive";
|
|
315933
315934
|
var DEFAULT_ARCHIVE_FORWARDER_PORT = 8090;
|
|
315934
315935
|
function isArchiveOtelLogsEnabled() {
|
|
@@ -315968,6 +315969,7 @@ class BrokerExecutionArchiver {
|
|
|
315968
315969
|
};
|
|
315969
315970
|
flushTimer = null;
|
|
315970
315971
|
flushInFlight = null;
|
|
315972
|
+
lastShedWarnAtMs = 0;
|
|
315971
315973
|
closed = false;
|
|
315972
315974
|
loggedMissingMarketForwarder = false;
|
|
315973
315975
|
enabled;
|
|
@@ -316032,6 +316034,15 @@ class BrokerExecutionArchiver {
|
|
|
316032
316034
|
this.recordArchiveMetric("cex_archive_rows_shed_total", {
|
|
316033
316035
|
table: row.table
|
|
316034
316036
|
});
|
|
316037
|
+
const now3 = Date.now();
|
|
316038
|
+
if (now3 - this.lastShedWarnAtMs >= SHED_WARN_INTERVAL_MS) {
|
|
316039
|
+
log.warn("Archive queue full: shedding oldest rows", {
|
|
316040
|
+
shed_total: this.stats.shed,
|
|
316041
|
+
queue_max: this.maxQueueSize,
|
|
316042
|
+
table: row.table
|
|
316043
|
+
});
|
|
316044
|
+
this.lastShedWarnAtMs = now3;
|
|
316045
|
+
}
|
|
316035
316046
|
}
|
|
316036
316047
|
this.queue.push(row);
|
|
316037
316048
|
this.stats.enqueued += 1;
|
|
@@ -332822,19 +332833,26 @@ class OhlcvBarTracker {
|
|
|
332822
332833
|
if (!firstBar || !lastBar) {
|
|
332823
332834
|
return [];
|
|
332824
332835
|
}
|
|
332825
|
-
|
|
332836
|
+
const lastOpenTimeMs = this.lastOpenTimeMs;
|
|
332837
|
+
if (lastOpenTimeMs !== null && lastBar.openTimeMs < lastOpenTimeMs) {
|
|
332838
|
+
return [];
|
|
332839
|
+
}
|
|
332840
|
+
const barsToProcess = lastOpenTimeMs === null ? bars : bars.filter((bar) => bar.openTimeMs >= lastOpenTimeMs);
|
|
332841
|
+
const firstBarToProcess = barsToProcess[0];
|
|
332842
|
+
const lastBarToProcess = barsToProcess[barsToProcess.length - 1];
|
|
332843
|
+
if (!firstBarToProcess || !lastBarToProcess) {
|
|
332826
332844
|
return [];
|
|
332827
332845
|
}
|
|
332828
332846
|
const candidates = [];
|
|
332829
|
-
if (this.lastBar !== null &&
|
|
332847
|
+
if (this.lastBar !== null && lastOpenTimeMs !== null && lastOpenTimeMs < firstBarToProcess.openTimeMs) {
|
|
332830
332848
|
candidates.push({
|
|
332831
332849
|
bar: this.lastBar,
|
|
332832
332850
|
isClosed: true,
|
|
332833
332851
|
brokerVersion
|
|
332834
332852
|
});
|
|
332835
332853
|
}
|
|
332836
|
-
for (let index2 = 0;index2 <
|
|
332837
|
-
const bar =
|
|
332854
|
+
for (let index2 = 0;index2 < barsToProcess.length - 1; index2 += 1) {
|
|
332855
|
+
const bar = barsToProcess[index2];
|
|
332838
332856
|
if (bar) {
|
|
332839
332857
|
candidates.push({
|
|
332840
332858
|
bar,
|
|
@@ -332844,12 +332862,12 @@ class OhlcvBarTracker {
|
|
|
332844
332862
|
}
|
|
332845
332863
|
}
|
|
332846
332864
|
candidates.push({
|
|
332847
|
-
bar:
|
|
332865
|
+
bar: lastBarToProcess,
|
|
332848
332866
|
isClosed: false,
|
|
332849
332867
|
brokerVersion
|
|
332850
332868
|
});
|
|
332851
|
-
this.lastOpenTimeMs =
|
|
332852
|
-
this.lastBar =
|
|
332869
|
+
this.lastOpenTimeMs = lastBarToProcess.openTimeMs;
|
|
332870
|
+
this.lastBar = lastBarToProcess;
|
|
332853
332871
|
return candidates;
|
|
332854
332872
|
}
|
|
332855
332873
|
}
|
|
@@ -333834,7 +333852,7 @@ function createSubscribeHandler(deps) {
|
|
|
333834
333852
|
}
|
|
333835
333853
|
}
|
|
333836
333854
|
while (ohlcvStreamActive && !isStreamClosed()) {
|
|
333837
|
-
const data = await broker.
|
|
333855
|
+
const data = await broker.watchOHLCV(resolvedSymbol, timeframe);
|
|
333838
333856
|
const receivedTimestamp = Date.now();
|
|
333839
333857
|
if (!await writeSubscribeFrame(call, isStreamClosed, {
|
|
333840
333858
|
data: JSON.stringify(data),
|
package/dist/index.js
CHANGED
|
@@ -275309,6 +275309,7 @@ var DEFAULT_MAX_QUEUE_SIZE = 1e4;
|
|
|
275309
275309
|
var DEFAULT_BATCH_SIZE = 10;
|
|
275310
275310
|
var DEFAULT_FLUSH_INTERVAL_MS = 1000;
|
|
275311
275311
|
var DEFAULT_FORWARDER_TIMEOUT_MS = 3000;
|
|
275312
|
+
var SHED_WARN_INTERVAL_MS = 60000;
|
|
275312
275313
|
var DEFAULT_ARCHIVE_FORWARDER_PATH = "/archive";
|
|
275313
275314
|
var DEFAULT_ARCHIVE_FORWARDER_PORT = 8090;
|
|
275314
275315
|
function isArchiveOtelLogsEnabled() {
|
|
@@ -275348,6 +275349,7 @@ class BrokerExecutionArchiver {
|
|
|
275348
275349
|
};
|
|
275349
275350
|
flushTimer = null;
|
|
275350
275351
|
flushInFlight = null;
|
|
275352
|
+
lastShedWarnAtMs = 0;
|
|
275351
275353
|
closed = false;
|
|
275352
275354
|
loggedMissingMarketForwarder = false;
|
|
275353
275355
|
enabled;
|
|
@@ -275412,6 +275414,15 @@ class BrokerExecutionArchiver {
|
|
|
275412
275414
|
this.recordArchiveMetric("cex_archive_rows_shed_total", {
|
|
275413
275415
|
table: row.table
|
|
275414
275416
|
});
|
|
275417
|
+
const now3 = Date.now();
|
|
275418
|
+
if (now3 - this.lastShedWarnAtMs >= SHED_WARN_INTERVAL_MS) {
|
|
275419
|
+
log.warn("Archive queue full: shedding oldest rows", {
|
|
275420
|
+
shed_total: this.stats.shed,
|
|
275421
|
+
queue_max: this.maxQueueSize,
|
|
275422
|
+
table: row.table
|
|
275423
|
+
});
|
|
275424
|
+
this.lastShedWarnAtMs = now3;
|
|
275425
|
+
}
|
|
275415
275426
|
}
|
|
275416
275427
|
this.queue.push(row);
|
|
275417
275428
|
this.stats.enqueued += 1;
|
|
@@ -295775,19 +295786,26 @@ class OhlcvBarTracker {
|
|
|
295775
295786
|
if (!firstBar || !lastBar) {
|
|
295776
295787
|
return [];
|
|
295777
295788
|
}
|
|
295778
|
-
|
|
295789
|
+
const lastOpenTimeMs = this.lastOpenTimeMs;
|
|
295790
|
+
if (lastOpenTimeMs !== null && lastBar.openTimeMs < lastOpenTimeMs) {
|
|
295791
|
+
return [];
|
|
295792
|
+
}
|
|
295793
|
+
const barsToProcess = lastOpenTimeMs === null ? bars : bars.filter((bar) => bar.openTimeMs >= lastOpenTimeMs);
|
|
295794
|
+
const firstBarToProcess = barsToProcess[0];
|
|
295795
|
+
const lastBarToProcess = barsToProcess[barsToProcess.length - 1];
|
|
295796
|
+
if (!firstBarToProcess || !lastBarToProcess) {
|
|
295779
295797
|
return [];
|
|
295780
295798
|
}
|
|
295781
295799
|
const candidates = [];
|
|
295782
|
-
if (this.lastBar !== null &&
|
|
295800
|
+
if (this.lastBar !== null && lastOpenTimeMs !== null && lastOpenTimeMs < firstBarToProcess.openTimeMs) {
|
|
295783
295801
|
candidates.push({
|
|
295784
295802
|
bar: this.lastBar,
|
|
295785
295803
|
isClosed: true,
|
|
295786
295804
|
brokerVersion
|
|
295787
295805
|
});
|
|
295788
295806
|
}
|
|
295789
|
-
for (let index2 = 0;index2 <
|
|
295790
|
-
const bar =
|
|
295807
|
+
for (let index2 = 0;index2 < barsToProcess.length - 1; index2 += 1) {
|
|
295808
|
+
const bar = barsToProcess[index2];
|
|
295791
295809
|
if (bar) {
|
|
295792
295810
|
candidates.push({
|
|
295793
295811
|
bar,
|
|
@@ -295797,12 +295815,12 @@ class OhlcvBarTracker {
|
|
|
295797
295815
|
}
|
|
295798
295816
|
}
|
|
295799
295817
|
candidates.push({
|
|
295800
|
-
bar:
|
|
295818
|
+
bar: lastBarToProcess,
|
|
295801
295819
|
isClosed: false,
|
|
295802
295820
|
brokerVersion
|
|
295803
295821
|
});
|
|
295804
|
-
this.lastOpenTimeMs =
|
|
295805
|
-
this.lastBar =
|
|
295822
|
+
this.lastOpenTimeMs = lastBarToProcess.openTimeMs;
|
|
295823
|
+
this.lastBar = lastBarToProcess;
|
|
295806
295824
|
return candidates;
|
|
295807
295825
|
}
|
|
295808
295826
|
}
|
|
@@ -296787,7 +296805,7 @@ function createSubscribeHandler(deps) {
|
|
|
296787
296805
|
}
|
|
296788
296806
|
}
|
|
296789
296807
|
while (ohlcvStreamActive && !isStreamClosed()) {
|
|
296790
|
-
const data = await broker.
|
|
296808
|
+
const data = await broker.watchOHLCV(resolvedSymbol, timeframe);
|
|
296791
296809
|
const receivedTimestamp = Date.now();
|
|
296792
296810
|
if (!await writeSubscribeFrame(call, isStreamClosed, {
|
|
296793
296811
|
data: JSON.stringify(data),
|
|
@@ -297412,4 +297430,4 @@ export {
|
|
|
297412
297430
|
CEXBroker as default
|
|
297413
297431
|
};
|
|
297414
297432
|
|
|
297415
|
-
//# debugId=
|
|
297433
|
+
//# debugId=1B2709360791D68C64756E2164756E21
|