gangtise-openapi-cli 0.14.3 → 0.14.4
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.
|
@@ -65,8 +65,22 @@ export async function callKlineWithSharding(client, endpointKey, body, config) {
|
|
|
65
65
|
if (process.env.GANGTISE_VERBOSE === "1" || process.env.GANGTISE_VERBOSE === "true") {
|
|
66
66
|
process.stderr.write(`[gangtise] sharding ${endpointKey} into ${shards.length} requests (${config.shardDays} day(s) each)\n`);
|
|
67
67
|
}
|
|
68
|
+
// Per-shard fault tolerance: a failing shard is recorded and skipped (returns a
|
|
69
|
+
// null sentinel) instead of rejecting, so the surviving shards still complete.
|
|
70
|
+
// runWithConcurrency uses Promise.all under the hood, which would otherwise abort
|
|
71
|
+
// every shard on the first rejection.
|
|
72
|
+
const failedShards = [];
|
|
73
|
+
let firstError = null;
|
|
68
74
|
const results = await runWithConcurrency(shards, config.concurrency ?? SHARD_CONCURRENCY, async (shard) => {
|
|
69
|
-
|
|
75
|
+
try {
|
|
76
|
+
return await client.call(endpointKey, { ...allMarketBody, startDate: shard.startDate, endDate: shard.endDate });
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
if (!firstError)
|
|
80
|
+
firstError = error;
|
|
81
|
+
failedShards.push(shard);
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
70
84
|
});
|
|
71
85
|
let fieldList;
|
|
72
86
|
let header = null;
|
|
@@ -82,10 +96,20 @@ export async function callKlineWithSharding(client, endpointKey, body, config) {
|
|
|
82
96
|
if (Array.isArray(rec.list))
|
|
83
97
|
merged.push(...rec.list);
|
|
84
98
|
}
|
|
99
|
+
// Every shard failed → surface the error loudly (non-zero exit) rather than
|
|
100
|
+
// masking a total outage as an empty success.
|
|
101
|
+
if (failedShards.length === shards.length) {
|
|
102
|
+
throw firstError ?? new Error(`All ${shards.length} kline shards failed`);
|
|
103
|
+
}
|
|
85
104
|
if (!header)
|
|
86
105
|
return { list: [] };
|
|
87
106
|
const out = { ...header, list: merged };
|
|
88
107
|
if (fieldList)
|
|
89
108
|
out.fieldList = fieldList;
|
|
109
|
+
if (failedShards.length > 0) {
|
|
110
|
+
out.partial = true;
|
|
111
|
+
out.failedShards = failedShards;
|
|
112
|
+
process.stderr.write(`[gangtise] warning: ${failedShards.length}/${shards.length} shards failed; results are partial (see failedShards)\n`);
|
|
113
|
+
}
|
|
90
114
|
return out;
|
|
91
115
|
}
|
package/dist/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Auto-generated — DO NOT EDIT
|
|
2
|
-
export const CLI_VERSION = "0.14.
|
|
2
|
+
export const CLI_VERSION = "0.14.4";
|