refactor(repository): deepen versioned cursor pagination behind shared helpers - #146
Open
allisson wants to merge 1 commit into
Open
refactor(repository): deepen versioned cursor pagination behind shared helpers#146allisson wants to merge 1 commit into
allisson wants to merge 1 commit into
Conversation
…d helpers Collapse the hand-rolled latest-version cursor JOIN and dry-run hard-delete SQL that the secrets, transit, and tokenization key repositories each copy-pasted behind two helpers in internal/database: - ListLatestCursor[T] owns the two-branch latest-version JOIN, row iteration, and empty-slice normalization; callers supply the table, key column, SELECT list, and a row scan callback. - HardDeleteOlderThan owns the dry-run count-vs-delete. Each key repository keeps its trivial Create/GetByKey/GetByKeyAndVersion/ Delete and delegates ListCursor (and HardDelete where the shape matches) to the seam. The tokenization TokenRepository.HardDelete is left as-is: it has an extra child-token cleanup step that would need a pre-delete hook. Also delete the unused offset-pagination List method on the secrets repository (not on the interface, no callers).
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
Collapses the hand-rolled latest-version cursor JOIN and dry-run hard-delete SQL that the
secrets,transit, andtokenizationkey repositories each copy-pasted, behind two helpers ininternal/database:ListLatestCursor[T]— owns the two-branch latest-version JOIN, row iteration, and empty-slice normalization; callers supply the table, key column, SELECT list, and a row scan callback.HardDeleteOlderThan— owns the dry-run count-vs-delete.Each key repository keeps its trivial
Create/GetByKey/GetByKeyAndVersion/Deleteand delegatesListCursor(andHardDeletewhere the shape matches) to the seam. The tokenizationTokenRepository.HardDeleteis intentionally left as-is — it has an extra child-token cleanup step that would require a pre-delete hook.Also deletes the unused offset-pagination
Listmethod on the secrets repository (not on the interface, no callers).Net: 311 lines removed, 199 added.
Validation
go build ./...— cleango vet ./...— cleangolangci-lint run --fix— cleango test ./...— all unit tests passgo test -tags=integration -p 1 ./...against Postgres — all integration tests passChangelog
Internal refactor with no API change — recorded under Unreleased → Changed.