@yarkivaev/scada 2.5.5 → 2.5.6

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/README.md CHANGED
@@ -219,6 +219,7 @@ Set `SINK_DB_PROFILE=central|edge`. Migrations run at supervisor-sink startup vi
219
219
  | `POSTGRES_ADMIN_URL` | Admin user for migrations |
220
220
  | `SINK_DB_PROFILE` | `central` or `edge` |
221
221
  | `SINK_PIPELINES` | `false` skips STOMP segment, decision, and alert consumers. The site container sets this and a `supervisor-sink` container keeps the default |
222
+ | `SEGMENT_REPAIR_HISTORY_ON_START` | `false` preserves closed historical boundaries at ingest startup. Omitted or `true` retains the existing same-name gap repair. Live ingest and silent-open handling remain active. |
222
223
  | `STATE_HTTP_PORT` / `STATE_HTTP_TOKEN` | Edge internal API |
223
224
  | `MQTT_URL`, `MQTT_TOPICS` | Optional metrics ingest |
224
225
  | `CLICKHOUSE_URL` | Central metrics sink |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yarkivaev/scada",
3
- "version": "2.5.5",
3
+ "version": "2.5.6",
4
4
  "description": "SCADA domain objects, state persistence, and plant monitoring",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,6 +30,14 @@ function milliseconds(env, key, fallback) {
30
30
  return value;
31
31
  }
32
32
 
33
+ function historyRepair(value) {
34
+ if (value === undefined) { return true; }
35
+ if (value !== 'true' && value !== 'false') {
36
+ throw new TypeError('SEGMENT_REPAIR_HISTORY_ON_START must be true or false');
37
+ }
38
+ return value === 'true';
39
+ }
40
+
33
41
  export function readDeploymentConfig(env) {
34
42
  const root = path.join(appRoot, '../..');
35
43
  const prefetch = Number(env.STOMP_PREFETCH || '128');
@@ -54,6 +62,7 @@ export function readDeploymentConfig(env) {
54
62
  requestTimeoutMs: parseRequestTimeoutMs(env.REQUEST_TIMEOUT_MS),
55
63
  pipelines: env.COLLECTOR_MODE !== 'external' && env.SINK_PIPELINES !== 'false',
56
64
  pipeline: {
65
+ repairHistoryOnStart: historyRepair(env.SEGMENT_REPAIR_HISTORY_ON_START),
57
66
  transactions: segmentTransactionConfig(env, dbPoolMax),
58
67
  maxMessageBytes: milliseconds(env, 'STOMP_MAX_MESSAGE_BYTES', 1048576),
59
68
  maxPendingBytes: milliseconds(env, 'STOMP_MAX_PENDING_BYTES', prefetch * 1048576),
@@ -43,6 +43,14 @@ function segmentSinks(postgres, pool) {
43
43
  };
44
44
  }
45
45
 
46
+ function pipelineSettings(config) {
47
+ const settings = config.transactions?.enabled ? { ...config, transactions: segmentBatchPolicy(config.transactions) } : config;
48
+ if (settings.repairHistoryOnStart !== undefined && typeof settings.repairHistoryOnStart !== 'boolean') {
49
+ throw new TypeError('repairHistoryOnStart must be boolean');
50
+ }
51
+ return settings;
52
+ }
53
+
46
54
  /**
47
55
  * Pipeline for streaming STOMP segment data to PostgreSQL segments table.
48
56
  * Subscribes to the durable ingest queue so shovel traffic survives consumer gaps.
@@ -56,7 +64,7 @@ function segmentSinks(postgres, pool) {
56
64
  * @returns {object} Pipeline with start() and stop() methods
57
65
  */
58
66
  export default function segmentPipeline(stomp, postgres, pool, config) {
59
- const settings = config.transactions?.enabled ? { ...config, transactions: segmentBatchPolicy(config.transactions) } : config;
67
+ const settings = pipelineSettings(config);
60
68
  const budget = silenceBudget(settings.segmentWindow || 15);
61
69
  const { segmentSink, splitSink } = segmentSinks(postgres, pool);
62
70
  const continued = continuedSegments(segmentSink, pool, budget);
@@ -89,10 +97,12 @@ export default function segmentPipeline(stomp, postgres, pool, config) {
89
97
  health() { return source.health(); },
90
98
  destination,
91
99
  async start() {
92
- const repair = abutSegments(pool, budget);
93
- void repair.catch((error) => {
94
- processingErrorLog('abut_segments', error, { budgetSeconds: budget });
95
- });
100
+ if (settings.repairHistoryOnStart !== false) {
101
+ const repair = abutSegments(pool, budget);
102
+ void repair.catch((error) => {
103
+ processingErrorLog('abut_segments', error, { budgetSeconds: budget });
104
+ });
105
+ }
96
106
  await source.start();
97
107
  await silence.start();
98
108
  },