Skip to content

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

Open
rustatian wants to merge 2 commits into
masterfrom
chore/cleanup-modernize-deps
Open

chore: simplify, modernize (Go 1.26), update deps#128
rustatian wants to merge 2 commits into
masterfrom
chore/cleanup-modernize-deps

Conversation

@rustatian
Copy link
Copy Markdown
Member

Applied fixes

R/High — health.go:27
/health returned 200 during shutdown instead of unavailableStatusCode. Fixed to match /ready behaviour — both now return unavailableStatusCode (503 by default) when shutdown is in progress.

M/Med — plugin.go:68
atomic.Pointer[bool]atomic.Bool. Removes new(bool) allocations and pointer dereferences in Init, Stop, and all three handler constructors (NewHealthHandler, NewReadyHandler, NewJobsHandler). Handler structs updated accordingly; test helper newShutdownPtr updated to match.

R/Med — health.go:111 / ready.go:114
Named-plugin path looked up svc to check ok, then discarded it and re-looked up the same key to call .Status()/.Ready(). Now uses the already-bound svc directly.

M/Low — health.go:111 / ready.go:114 / jobs.go:47
for i := range plg { … plg[i] … }for _, name := range plg (Go 1.22 range-over-value).

R/Med — jobs.go:38
JobsState(context.Background())JobsState(r.Context()) so cancellation propagates from the HTTP request.

Minor
Report slices pre-sized to len(registry) instead of a fixed cap 2.

Not applied (needs manual review)

  • R/Med health.go:95 — header may already be written in the all-plugins loop before the final json.Marshal + w.Write. The asymmetric early-return and the mixed WriteHeader/Write ordering need a more invasive refactor (response buffer or tracking whether header was sent). Left for a separate pass.
  • R/Med ready.go:29 — structurally identical to health; same reasoning.
  • S/Med health.go:26 / ready.go:29 — "all vs named" switch deduplication helper. Worthwhile but a larger change; skipped to keep this PR minimal.
  • M/Low config.go:20CheckTimeout inttime.Duration. Breaks the existing mapstructure field (users would need to change their config format); intentionally skipped.

Deps

go get -u all && go mod tidy on root and tests/; go work sync on the workspace. No version changes were needed (all deps already current).

Verification

go build ./...   ✓
go vet ./...     ✓
golangci-lint run  0 issues
go test ./...    ok  github.com/roadrunner-server/status/v6

- fix: /health returned 200 during shutdown (should be unavailableStatusCode, same as /ready)
- refactor: atomic.Pointer[bool] → atomic.Bool; drop new(bool) stores and pointer derefs
- fix: named-plugin paths used svc from the ok-check then re-looked up via map index — now use svc directly
- modernize: for-index loops over plg slice → range-over-value (Go 1.22)
- fix: jobs handler now threads r.Context() into JobsState instead of context.Background()
- modernize: report slice pre-sized to registry len instead of fixed cap 2
Copilot AI review requested due to automatic review settings May 29, 2026 12:46
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

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 25 minutes and 18 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: 39c2e002-742a-4aac-8179-40116a9d98d7

📥 Commits

Reviewing files that changed from the base of the PR and between 09a3f4a and 82aca85.

📒 Files selected for processing (5)
  • handler_test.go
  • health.go
  • jobs.go
  • plugin.go
  • ready.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.

Copy link
Copy Markdown

Copilot AI left a comment

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 the status service HTTP handlers and plugin shutdown signaling, aiming to reduce allocations, improve correctness during shutdown, and streamline handler logic.

Changes:

  • Replace atomic.Pointer[bool] shutdown flag usage with atomic.Bool across plugin and handlers.
  • Align /health shutdown behavior with configured UnavailableStatusCode, and simplify handler loops / reduce redundant map lookups.
  • Improve handler efficiency and behavior (pre-size report slices, range-over-values, and propagate request cancellation to jobs checks via r.Context()).

Reviewed changes

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

Show a summary per file
File Description
plugin.go Switch shutdown flag storage to atomic.Bool and update handler wiring; adjust shutdown semantics.
health.go Use UnavailableStatusCode on shutdown; pre-size report slice; simplify named-plugin loop and avoid redundant lookups.
ready.go Pre-size report slice; simplify named-plugin loop and avoid redundant lookups; shutdown flag now atomic.Bool.
jobs.go Use request context for JobsState; simplify report building loop; shutdown flag now atomic.Bool.
handler_test.go Update shutdown helper for atomic.Bool and adjust shutdown expectation for /health.

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

Comment thread ready.go Outdated
Comment thread jobs.go Outdated
Comment thread plugin.go Outdated
Shutdown path in Ready and Jobs handlers was hard-coding 503 instead of
respecting the handler's configured unavailableStatusCode field, making
the setting ineffective on graceful shutdown. Update the Stop() comment
to match.
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