@shipfox/api-logs 6.0.0 → 8.0.0
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/.turbo/turbo-build.log +14 -14
- package/CHANGELOG.md +22 -0
- package/dist/api/object-storage.d.ts.map +1 -1
- package/dist/api/object-storage.js +28 -2
- package/dist/api/object-storage.js.map +1 -1
- package/dist/core/append-logs.d.ts.map +1 -1
- package/dist/core/append-logs.js +1 -1
- package/dist/core/append-logs.js.map +1 -1
- package/dist/core/reap-stale-open-streams.d.ts.map +1 -1
- package/dist/core/reap-stale-open-streams.js +7 -0
- package/dist/core/reap-stale-open-streams.js.map +1 -1
- package/dist/core/retention.d.ts.map +1 -1
- package/dist/core/retention.js +25 -0
- package/dist/core/retention.js.map +1 -1
- package/dist/core/session/parse-session.d.ts +1 -1
- package/dist/core/session/parse-session.d.ts.map +1 -1
- package/dist/core/session/parse-session.js.map +1 -1
- package/dist/temporal/activities/compact-stream.d.ts.map +1 -1
- package/dist/temporal/activities/compact-stream.js +17 -1
- package/dist/temporal/activities/compact-stream.js.map +1 -1
- package/dist/temporal/activities/compaction-reconcile.d.ts.map +1 -1
- package/dist/temporal/activities/compaction-reconcile.js +7 -0
- package/dist/temporal/activities/compaction-reconcile.js.map +1 -1
- package/dist/temporal/workflows/index.bundle.js +17164 -3306
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +9 -30
- package/src/api/object-storage.ts +21 -2
- package/src/core/append-logs.ts +1 -1
- package/src/core/reap-stale-open-streams.ts +2 -0
- package/src/core/retention.ts +5 -0
- package/src/core/session/parse-session.ts +1 -1
- package/src/presentation/routes/append-logs.test.ts +2 -3
- package/src/temporal/activities/compact-stream.ts +13 -1
- package/src/temporal/activities/compaction-reconcile.ts +2 -0
- package/test/fixtures/lease-token.ts +31 -27
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compaction-reconcile.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/compaction-reconcile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compaction-reconcile.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/compaction-reconcile.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;GAUG;AACH,wBAAsB,2BAA2B,IAAI,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAAC,CA4BhG"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { reportError } from '@shipfox/node-error-monitoring';
|
|
1
2
|
import { logger } from '@shipfox/node-opentelemetry';
|
|
2
3
|
import { temporalClient } from '@shipfox/node-temporal';
|
|
3
4
|
import { config } from '#config.js';
|
|
@@ -41,6 +42,12 @@ const RECONCILE_BATCH_LIMIT = 100;
|
|
|
41
42
|
err: error,
|
|
42
43
|
streamId: stream.id
|
|
43
44
|
}, 'Failed to re-drive stale stream compaction');
|
|
45
|
+
reportError(error, {
|
|
46
|
+
boundary: 'logs.maintenance',
|
|
47
|
+
extra: {
|
|
48
|
+
streamId: stream.id
|
|
49
|
+
}
|
|
50
|
+
});
|
|
44
51
|
}
|
|
45
52
|
}
|
|
46
53
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/temporal/activities/compaction-reconcile.ts"],"sourcesContent":["import {logger} from '@shipfox/node-opentelemetry';\nimport {temporalClient} from '@shipfox/node-temporal';\nimport {config} from '#config.js';\nimport {listStaleUncompactedStreams} from '#db/streams.js';\nimport {LOGS_COMPACTION_TASK_QUEUE} from '#temporal/constants.js';\n\n// Bounded per tick; remaining stale streams are picked up on the next cron run.\nconst RECONCILE_BATCH_LIMIT = 100;\n\n/**\n * Backstop for the event-triggered path: finds closed streams that never got an object\n * key past the stale window and re-starts compaction for each. Starting by the same\n * `logs-compact:{streamId}` workflow id re-drives a stream whose bounded-retry run already\n * failed and closed, while skipping one whose run is still RUNNING (AlreadyStarted). Starts\n * independent workflows, not children, so a re-driven run is not tied to this cron tick.\n *\n * One stream's unexpected start failure is logged and skipped, never thrown: a single poison\n * stream must not abort the batch and leave the rest of the backlog un-re-driven (the next\n * tick retries it). The activity only fails on the initial DB query.\n */\nexport async function compactionReconcileActivity(): Promise<{restarted: number; failed: number}> {\n const stale = await listStaleUncompactedStreams({\n olderThanSeconds: config.LOG_COMPACTION_RECONCILE_STALE_SECONDS,\n limit: RECONCILE_BATCH_LIMIT,\n });\n\n let restarted = 0;\n let failed = 0;\n for (const stream of stale) {\n try {\n await temporalClient().workflow.start('compactStream', {\n taskQueue: LOGS_COMPACTION_TASK_QUEUE,\n workflowId: `logs-compact:${stream.id}`,\n args: [{streamId: stream.id}],\n });\n restarted += 1;\n } catch (error) {\n if (error instanceof Error && error.name === 'WorkflowExecutionAlreadyStartedError') continue;\n failed += 1;\n logger().error(\n {err: error, streamId: stream.id},\n 'Failed to re-drive stale stream compaction',\n );\n }\n }\n\n return {restarted, failed};\n}\n"],"names":["logger","temporalClient","config","listStaleUncompactedStreams","LOGS_COMPACTION_TASK_QUEUE","RECONCILE_BATCH_LIMIT","compactionReconcileActivity","stale","olderThanSeconds","LOG_COMPACTION_RECONCILE_STALE_SECONDS","limit","restarted","failed","stream","workflow","start","taskQueue","workflowId","id","args","streamId","error","Error","name","err"],"mappings":"AAAA,SAAQA,MAAM,QAAO,8BAA8B;AACnD,SAAQC,cAAc,QAAO,yBAAyB;AACtD,SAAQC,MAAM,QAAO,aAAa;AAClC,SAAQC,2BAA2B,QAAO,iBAAiB;AAC3D,SAAQC,0BAA0B,QAAO,yBAAyB;AAElE,gFAAgF;AAChF,MAAMC,wBAAwB;AAE9B;;;;;;;;;;CAUC,GACD,OAAO,eAAeC;IACpB,MAAMC,QAAQ,MAAMJ,4BAA4B;QAC9CK,kBAAkBN,OAAOO,sCAAsC;QAC/DC,OAAOL;IACT;IAEA,IAAIM,YAAY;IAChB,IAAIC,SAAS;IACb,KAAK,MAAMC,UAAUN,MAAO;QAC1B,IAAI;YACF,MAAMN,iBAAiBa,QAAQ,CAACC,KAAK,CAAC,iBAAiB;gBACrDC,WAAWZ;gBACXa,YAAY,CAAC,aAAa,EAAEJ,OAAOK,EAAE,EAAE;gBACvCC,MAAM;oBAAC;wBAACC,UAAUP,OAAOK,EAAE;oBAAA;iBAAE;YAC/B;YACAP,aAAa;QACf,EAAE,OAAOU,OAAO;YACd,IAAIA,iBAAiBC,SAASD,MAAME,IAAI,KAAK,wCAAwC;YACrFX,UAAU;YACVZ,SAASqB,KAAK,CACZ;gBAACG,KAAKH;gBAAOD,UAAUP,OAAOK,EAAE;YAAA,GAChC;
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/activities/compaction-reconcile.ts"],"sourcesContent":["import {reportError} from '@shipfox/node-error-monitoring';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {temporalClient} from '@shipfox/node-temporal';\nimport {config} from '#config.js';\nimport {listStaleUncompactedStreams} from '#db/streams.js';\nimport {LOGS_COMPACTION_TASK_QUEUE} from '#temporal/constants.js';\n\n// Bounded per tick; remaining stale streams are picked up on the next cron run.\nconst RECONCILE_BATCH_LIMIT = 100;\n\n/**\n * Backstop for the event-triggered path: finds closed streams that never got an object\n * key past the stale window and re-starts compaction for each. Starting by the same\n * `logs-compact:{streamId}` workflow id re-drives a stream whose bounded-retry run already\n * failed and closed, while skipping one whose run is still RUNNING (AlreadyStarted). Starts\n * independent workflows, not children, so a re-driven run is not tied to this cron tick.\n *\n * One stream's unexpected start failure is logged and skipped, never thrown: a single poison\n * stream must not abort the batch and leave the rest of the backlog un-re-driven (the next\n * tick retries it). The activity only fails on the initial DB query.\n */\nexport async function compactionReconcileActivity(): Promise<{restarted: number; failed: number}> {\n const stale = await listStaleUncompactedStreams({\n olderThanSeconds: config.LOG_COMPACTION_RECONCILE_STALE_SECONDS,\n limit: RECONCILE_BATCH_LIMIT,\n });\n\n let restarted = 0;\n let failed = 0;\n for (const stream of stale) {\n try {\n await temporalClient().workflow.start('compactStream', {\n taskQueue: LOGS_COMPACTION_TASK_QUEUE,\n workflowId: `logs-compact:${stream.id}`,\n args: [{streamId: stream.id}],\n });\n restarted += 1;\n } catch (error) {\n if (error instanceof Error && error.name === 'WorkflowExecutionAlreadyStartedError') continue;\n failed += 1;\n logger().error(\n {err: error, streamId: stream.id},\n 'Failed to re-drive stale stream compaction',\n );\n reportError(error, {boundary: 'logs.maintenance', extra: {streamId: stream.id}});\n }\n }\n\n return {restarted, failed};\n}\n"],"names":["reportError","logger","temporalClient","config","listStaleUncompactedStreams","LOGS_COMPACTION_TASK_QUEUE","RECONCILE_BATCH_LIMIT","compactionReconcileActivity","stale","olderThanSeconds","LOG_COMPACTION_RECONCILE_STALE_SECONDS","limit","restarted","failed","stream","workflow","start","taskQueue","workflowId","id","args","streamId","error","Error","name","err","boundary","extra"],"mappings":"AAAA,SAAQA,WAAW,QAAO,iCAAiC;AAC3D,SAAQC,MAAM,QAAO,8BAA8B;AACnD,SAAQC,cAAc,QAAO,yBAAyB;AACtD,SAAQC,MAAM,QAAO,aAAa;AAClC,SAAQC,2BAA2B,QAAO,iBAAiB;AAC3D,SAAQC,0BAA0B,QAAO,yBAAyB;AAElE,gFAAgF;AAChF,MAAMC,wBAAwB;AAE9B;;;;;;;;;;CAUC,GACD,OAAO,eAAeC;IACpB,MAAMC,QAAQ,MAAMJ,4BAA4B;QAC9CK,kBAAkBN,OAAOO,sCAAsC;QAC/DC,OAAOL;IACT;IAEA,IAAIM,YAAY;IAChB,IAAIC,SAAS;IACb,KAAK,MAAMC,UAAUN,MAAO;QAC1B,IAAI;YACF,MAAMN,iBAAiBa,QAAQ,CAACC,KAAK,CAAC,iBAAiB;gBACrDC,WAAWZ;gBACXa,YAAY,CAAC,aAAa,EAAEJ,OAAOK,EAAE,EAAE;gBACvCC,MAAM;oBAAC;wBAACC,UAAUP,OAAOK,EAAE;oBAAA;iBAAE;YAC/B;YACAP,aAAa;QACf,EAAE,OAAOU,OAAO;YACd,IAAIA,iBAAiBC,SAASD,MAAME,IAAI,KAAK,wCAAwC;YACrFX,UAAU;YACVZ,SAASqB,KAAK,CACZ;gBAACG,KAAKH;gBAAOD,UAAUP,OAAOK,EAAE;YAAA,GAChC;YAEFnB,YAAYsB,OAAO;gBAACI,UAAU;gBAAoBC,OAAO;oBAACN,UAAUP,OAAOK,EAAE;gBAAA;YAAC;QAChF;IACF;IAEA,OAAO;QAACP;QAAWC;IAAM;AAC3B"}
|