Skip to content

refactor: share sqlite close helper across storage packages#88

Merged
klauern merged 2 commits intomainfrom
codex/refactor-shared-storage-close-helper
May 1, 2026
Merged

refactor: share sqlite close helper across storage packages#88
klauern merged 2 commits intomainfrom
codex/refactor-shared-storage-close-helper

Conversation

@klauern
Copy link
Copy Markdown
Owner

@klauern klauern commented May 1, 2026

Summary

  • add shared helper
  • replace duplicated implementations in and
  • preserve existing warning message format and callsites

Testing

  • ok github.com/klauer/clash-royale-api/go/pkg/fuzzstorage 0.279s
    ok github.com/klauer/clash-royale-api/go/pkg/leaderboard 0.520s

Refs: clash-royale-api-1qc

Summary by CodeRabbit

  • Refactor
    • Consolidated resource management and logging implementation to improve consistency across storage operations.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

Warning

Rate limit exceeded

@klauern has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 59 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8037cc7e-0c4b-405f-af04-a143b31a38aa

📥 Commits

Reviewing files that changed from the base of the PR and between 0addb19 and 547c5cb.

📒 Files selected for processing (3)
  • internal/storageutil/close.go
  • pkg/fuzzstorage/storage.go
  • pkg/leaderboard/storage.go
📝 Walkthrough

Walkthrough

This PR introduces a centralized CloseWithLog utility function in internal/storageutil and refactors pkg/fuzzstorage and pkg/leaderboard to use it instead of maintaining duplicate close-and-log helpers locally. This consolidates code duplication across resource cleanup operations.

Changes

Cohort / File(s) Summary
New Utility Function
internal/storageutil/close.go
Introduces CloseWithLog function that wraps io.Closer.Close() and logs warnings when close operations fail with the resource name and error.
Storage Refactoring
pkg/fuzzstorage/storage.go, pkg/leaderboard/storage.go
Removes duplicate local closeWithLog helper functions and imports; updates all close call sites in NewStorage, Query, GetTopN, GetByArchetype, GetArchetypeCounts, and ArchetypeHistogram to use centralized storageutil.CloseWithLog.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Resources close with gentle care,
Logs now shared, beyond compare!
No more duplication's tangled weave—
One helper true, we all believe!
Errors logged when closers misbehave! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: refactoring to share a SQLite close helper across storage packages, which matches the changeset that adds CloseWithLog to storageutil and removes duplicate implementations from fuzzstorage and leaderboard.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/refactor-shared-storage-close-helper

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 51 minutes and 59 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@klauern klauern force-pushed the codex/refactor-shared-storage-close-helper branch from 0addb19 to 1fec750 Compare May 1, 2026 15:09
@klauern klauern merged commit 35572dd into main May 1, 2026
9 checks passed
@klauern klauern deleted the codex/refactor-shared-storage-close-helper branch May 1, 2026 15:14
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