Skip to content

chore: simplify, modernize (Go 1.26), update deps#220

Merged
rustatian merged 3 commits into
masterfrom
chore/cleanup-modernize-deps
Jun 3, 2026
Merged

chore: simplify, modernize (Go 1.26), update deps#220
rustatian merged 3 commits into
masterfrom
chore/cleanup-modernize-deps

Conversation

@rustatian

@rustatian rustatian commented May 29, 2026

Copy link
Copy Markdown
Member

Applied fixes

R — Bug fixes (2)

  • memorykv/driver.goMExpire: add ttm <= 0 guard mirroring Set; prevents time.NewTicker(0) and ta.Reset(0) panics when a past/expired TTL is supplied

M — Modern Go (4)

  • memorykv/driver.go — replace == nil variadic guards with len(keys/items) == 0 in Has, MGet, Set, TTL, Delete
  • memorykv/driver.go — range-over-value (for _, k := range keys / for _, it := range items) in all loops
  • memoryjobs/driver.gogoroutines.Add(^uint64(0)) already modern; no change needed
  • memoryjobs/item.go — move encoding/json into the stdlib import group

S — Simplify (3)

  • memoryjobs/driver.go — use sync.NewCond(&sync.Mutex{}) constructor in FromConfig and FromPipeline
  • memoryjobs/driver.go — reuse captured start/t variable in log calls instead of re-calling time.Now().UTC()
  • memorykv/driver.go — remove redundant blocking stopCh send in Delete; LoadAndDelete already signals the callback via a non-blocking select

- memorykv: guard nil-variadic with len==0 in Has/MGet/Set/TTL/Delete
- memorykv: range-over-value in all key/item loops
- memorykv: fix MExpire ttm<=0 panic (NewTicker(0)/Reset(0)); mirror Set guard
- memorykv: remove redundant blocking stopCh send in Delete (LoadAndDelete handles it)
- memoryjobs: use sync.NewCond constructor in FromConfig and FromPipeline
- memoryjobs: reuse captured start time in log calls instead of re-evaluating time.Now()
- memoryjobs: fix encoding/json import grouping in item.go
Copilot AI review requested due to automatic review settings May 29, 2026 12:32
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@rustatian, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 29 minutes and 23 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aada2089-ed91-4769-91db-395b5c032a28

📥 Commits

Reviewing files that changed from the base of the PR and between 5b0e272 and d276760.

⛔ Files ignored due to path filters (1)
  • go.work.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • memoryjobs/driver.go
  • memoryjobs/item.go
  • memorykv/driver.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/cleanup-modernize-deps

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

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes and simplifies the in-memory KV and jobs drivers, while addressing a TTL edge case that can panic when an already-expired TTL is supplied.

Changes:

  • Update KV driver variadic argument guards (len(...) == 0) and simplify loops (for _, v := range ...).
  • Add an expired/invalid TTL guard in MExpire to avoid time.NewTicker(0) / Reset(0) panics.
  • Simplify jobs driver initialization/logging (sync.NewCond(...), reuse captured start timestamps) and reorder stdlib imports.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
memorykv/driver.go Refactors variadic guards/loops, adjusts TTL handling (including MExpire) and simplifies delete logic.
memoryjobs/driver.go Uses sync.NewCond constructor and reuses captured start times in lifecycle logs.
memoryjobs/item.go Moves encoding/json into the stdlib import group.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread memorykv/driver.go
Comment thread memoryjobs/driver.go
… MExpire

When MExpire received an expired TTL (ttm <= 0) it called heap.Set directly,
leaving any existing callback goroutine alive. That goroutine could later fire
removeEntry and silently delete the newly saved item. Call heap.Delete first to
signal the old callback's stopCh before writing the new non-TTL entry.
@rustatian rustatian self-assigned this Jun 3, 2026
Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
@rustatian rustatian merged commit 758aa36 into master Jun 3, 2026
7 of 9 checks passed
@rustatian rustatian deleted the chore/cleanup-modernize-deps branch June 3, 2026 20:11
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.

2 participants