feat(listener): add automatic cleanup service for events and DB rows#210
Open
susanyusuf wants to merge 1 commit into
Open
feat(listener): add automatic cleanup service for events and DB rows#210susanyusuf wants to merge 1 commit into
susanyusuf wants to merge 1 commit into
Conversation
|
@susanyusuf Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #100
Closes #63
Closes #179
Closes #177
Description 1. listener/src/services/cleanup-service.ts (new file)
Introduced a Cleanup Service class that runs on a configurable
interval and deletes stale database rows from two tables:
COMPLETED, FAILED, or CANCELLED older than the configured
retention period (default: 7 days)
configured retention period (default: 24 hours)
Also delegates in-memory event pruning to EventRegistry via
startCleanup() / stopCleanup().
Bug fixed: logger.info('CleanupService started', this.config)
caused a TypeScript compile error because CleanupConfig
an index signature required by the logger's Record string,
Record<string, unknown> parameter type. Fixed with
this.config as unknown as Record<string, unknown.
Test suite covering:
events kept, interval start/stop)
behavior, idempotent start(), clean stop())
Extended EventRegistry to support TTL-based expiry:
timestamp is older than ttlMs
self-managed setInterval for automatic pruning
Added the AppCleanupConfig interface defining four configurable
retention/interval values:
in the DB
rows
Also added cleanup?: AppCleanupConfig to the main Config
interface.
5. listener/src/config.ts
Added loadCleanupConfig() which reads the four new retention
values from environment variables (CLEANUP_INTERVAL_MS,
NOTIFICATION_RETENTION_MS, RATE_LIMIT_EVENT_RETENTION_MS,
EVENT_RETENTION_MS) with sensible defaults. The result is
merged into the main config object returned by loadConfig().
6. listener/src/index.ts
Wired CleanupService into the application lifecycle:
settings
alongside other services
config before the service starts