refactor(storage): extract SlowLogRepository across all three storage adapters#191
Open
amitkojha05 wants to merge 1 commit into
Open
refactor(storage): extract SlowLogRepository across all three storage adapters#191amitkojha05 wants to merge 1 commit into
amitkojha05 wants to merge 1 commit into
Conversation
78f20c3 to
891a582
Compare
Contributor
Author
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.
Summary
Extracts slow log query logic from the three storage adapters into dedicated
SlowLogRepositoryclasses, continuing the repository extraction started in #125 (webhooks).New files:
repositories/slowlog.postgres.repository.tsrepositories/slowlog.sqlite.repository.tsrepositories/slowlog.memory.repository.tsModified files:
postgres.adapter.ts— delegates toSlowLogPostgresRepositorysqlite.adapter.ts— delegates toSlowLogSqliteRepositorymemory.adapter.ts— delegates toSlowLogMemoryRepositoryChanges
The TODO comment in
postgres.adapter.ts(left in #125) lists slowlog as the next domain to extract:This removes ~200 lines of inline query logic from each SQL adapter and isolates slow log storage behind testable, single-responsibility classes.
Implementation
Same pattern as #125:
Pool,Database.Database) — the type system guarantees a live connectionif (!this.pool)/if (!this.db)lifecycle guards and delegate after initializationStoredSlowLogEntry[])entries.length === 0short-circuit lives in both the adapter (preserving original behaviour) and the repository (for standalon testability)Testing
Pure extraction — zero SQL changes, zero logic changes, zero interface changes. All existing tests pass unchanged.
CI note
CI note: the anomaly.service.spec.ts failure (getClusterInfo mock missing at line 733) was introduced in #142 (feat: sentinel/cluster failover — commit 2fa1c46) and is pre-existing on master. Unrelated to this SlowLog extraction.