Skip to content

Feat/idempotency cleanup - #1009

Open
Johnsource-hub wants to merge 8 commits into
scout-off:mainfrom
Johnsource-hub:feat/idempotency-cleanup
Open

Feat/idempotency cleanup#1009
Johnsource-hub wants to merge 8 commits into
scout-off:mainfrom
Johnsource-hub:feat/idempotency-cleanup

Conversation

@Johnsource-hub

Copy link
Copy Markdown

#closes
#803

New files:

  • db/014_idempotency_cleanup_index.sql — Migration adding idx_idempotency_keys_created_at index
  • src/services/idempotencyCleanup.ts — Cleanup job with IdempotencyCleanupDriver abstraction, deleteExpiredIdempotencyKeys(), and startIdempotencyCleanupJob() (hourly setInterval, skips when NODE_ENV=test, logs deleted count at debug, increments Prometheus counter)
  • tests/services/idempotencyCleanup.test.ts — 3 tests: deletes only expired rows, keeps recent rows, skips job in test env
    Modified files:
  • src/middleware/metrics.ts:17-21 — Added idempotencyKeysDeletedTotal Prometheus counter
  • src/middleware/idempotency.ts:45-49 — Added created_at index creation in initializeDatabase()
  • src/middleware/idempotency.ts:155-161 — Exported cleanupDriver implementing IdempotencyCleanupDriver
  • src/index.ts:13-14 — Imported cleanupDriver and startIdempotencyCleanupJob; wired up on line 147
  • mocks/better-sqlite3.js — Updated mock's DELETE FROM IDEMPOTENCY_KEYS handler to support created_at-based deletion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant