Skip to content

feat: migrate to Connect-RPC; new wire path /jobs.v2.JobsService/#147

Merged
rustatian merged 7 commits into
masterfrom
fix-declare-priority-default
May 10, 2026
Merged

feat: migrate to Connect-RPC; new wire path /jobs.v2.JobsService/#147
rustatian merged 7 commits into
masterfrom
fix-declare-priority-default

Conversation

@rustatian

@rustatian rustatian commented May 10, 2026

Copy link
Copy Markdown
Member

Summary

Switches the jobs plugin's RPC layer from net/rpc + goridge codec to Connect-RPC over HTTP/2. Plugin.RPC() now returns the generated jobsV2connect.NewJobsServiceHandler, which the rpc plugin (≥ v6.0.0-beta.4) mounts at /jobs.v2.JobsService/ on its HTTP/2 mux.

The 8 wire methods are reshaped from net/rpc's (req, *resp) error to the Connect handler interface. Notable contract changes:

  • Push now takes PushRequest { Job job = 1; } — proto-shape enforces single-job, the legacy len(req.Batch) != 1 runtime guard is gone.
  • StatGetStats (proto rename to avoid same-package collision with the Stat message).
  • List, GetStats take google.protobuf.Empty.
  • Errors wrap via connect.NewError(connect.CodeInternal, errors.E(op, err)); OTEL spans + per-method mutex preserved.
  • Push-side trace-context extraction from job headers now layers on the inbound handler ctx so client cancellation/deadline propagates (PHP-side trace propagation still wins for the span parent).

Test helpers swapped to an h2c Connect client (jobsV2connect.JobsServiceClient) talking to the rpc plugin's HTTP/2 cleartext listener at 127.0.0.1:6001. Exported helpers.NewJobsClient(t, address) for sibling test packages. Variadic-pipes copies use slices.Clone(pipes) (Go 1.21+ idiom).

Also fixes a pre-existing Plugin.Declare priority bug (surfaced during the silent-failure-hunter review and folded into this PR): when a pipeline's priority field was non-numeric, strconv.Atoi failed and prInt was silently saved as 0 rather than the documented default of 10. Now the parse-error branch resets prInt = 10 and the log line surfaces the chosen fallback.

Deps:

  • api-go/v6 v6.0.0-beta.4 → v6.0.0-beta.5 (new JobsService bindings)
  • goridge/v4 v4.0.0-beta.1 → v4.0.0-beta.2 (pkg/rpc removed)
  • rpc/v6 v6.0.0-beta.3 → v6.0.0-beta.4 (Connect-based RPCer interface)
  • + connectrpc.com/connect, + golang.org/x/net (h2c transport for tests)

Breaking changes

  • Wire protocol changes from goridge codec (raw TCP frames at 127.0.0.1:6001) to Connect/gRPC over HTTP/2 at /jobs.v2.JobsService/<Method>. Downstream Go consumers must use jobsV2connect.NewJobsServiceClient (or any gRPC client). The PHP goridge client migrates separately on its own timeline.
  • Push request type changed from PushBatchRequest (1-element) to PushRequest { Job }.
  • Stat RPC method renamed to GetStats.

rustatian added 4 commits May 10, 2026 14:08
Switches the jobs plugin from net/rpc + goridge codec to Connect-RPC.
Plugin.RPC() now returns the generated jobsV2connect.NewJobsServiceHandler
mounted at /jobs.v2.JobsService/ on the rpc plugin's HTTP/2 mux.

The 8 wire methods are reshaped from (req, *resp) error to the Connect
handler interface:
  Push, PushBatch, Pause, Resume, List, Declare, Destroy, GetStats

Notable shape changes:
- Push now takes PushRequest { Job job = 1; }; the legacy runtime guard
  for "exactly one job" inside PushBatchRequest is gone (proto enforces).
- Stat -> GetStats (proto rename to avoid collision with the Stat message).
- List, GetStats take google.protobuf.Empty.
- Errors wrap via connect.NewError(connect.CodeInternal, ...) for proper
  gRPC status codes; OTEL spans + per-method mutex preserved.

Test helpers swapped to an h2c Connect client (jobsV2connect.JobsServiceClient)
talking to the rpc plugin's HTTP/2 cleartext listener at 127.0.0.1:6001.

Deps:
- api-go v6.0.0-beta.4 -> v6.0.0-beta.5 (new JobsService bindings)
- goridge v4.0.0-beta.1 -> v4.0.0-beta.2 (pkg/rpc removed)
- rpc/v6 v6.0.0-beta.3 -> v6.0.0-beta.4 (Connect-based RPCer interface)
- + connectrpc.com/connect, + golang.org/x/net (h2c client in tests)

Breaking changes:
- Wire protocol changes from goridge codec to Connect/gRPC. Downstream
  consumers must use jobsV2connect.NewJobsServiceClient (or any gRPC
  client) against the new path. The PHP goridge client migrates
  separately on its own timeline.
- Push/PushBatch: thread inbound handler ctx through rpcContextFromJob/
  rpcContextFromJobs/rpcContextFromHeaders so client cancellation and
  deadlines propagate. The job-header trace context still overrides the
  span parent (PHP-side propagation preserved); only the propagator's
  parent argument changes.
- Pause/Resume: wrap errors with errors.E(op, err) for consistency
  with other methods (rpc_pause, rpc_resume ops).
- Tests (helpers): t.Cleanup(httpc.CloseIdleConnections) on each
  NewJobsClient to avoid leaking idle HTTP/2 connections across tests.
- rpc_test.go: pass t.Context() to the 5 helper call sites for the new
  signature.
- Destroy: wrap errg.Wait() error with errors.E(op, err) for parity
  with the other 7 methods.
- Push: add unit tests covering nil-job and empty-ID branches (the
  proto-shape replacement for the legacy len(req.Batch) != 1 guard).
- Trim WHAT-restating docstrings on Plugin.RPC, rpc.from, rpc.Push,
  rpc.Declare, helpers.NewJobsClient. Tighten the rpcContextFromJobs
  doc to the single non-obvious WHY (parent-ctx layering).
When a pipeline's priority field is present but non-numeric, strconv.Atoi
left prInt at its zero value, which Plugin.Declare then saved as the
pipeline's priority — silently coercing user input to 0 despite the
"continue with default priority" comment that implies 10 (the same
fallback used for missing priority on the line above).

Now the parse-error branch resets prInt to 10 to match the comment, and
the log line surfaces the chosen fallback so operators can see when their
priority value was rejected.
Copilot AI review requested due to automatic review settings May 10, 2026 12:45
@coderabbitai

coderabbitai Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

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

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ 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: 1b00d922-e488-48cf-aa87-5be9de8fe479

📥 Commits

Reviewing files that changed from the base of the PR and between 6e0e046 and 2343f25.

⛔ Files ignored due to path filters (3)
  • go.sum is excluded by !**/*.sum
  • go.work.sum is excluded by !**/*.sum
  • tests/go.sum is excluded by !**/*.sum
📒 Files selected for processing (7)
  • go.mod
  • plugin.go
  • rpc.go
  • rpc_test.go
  • tests/go.mod
  • tests/helpers/helpers.go
  • tests/jobs_general_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-declare-priority-default

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

Fixes Plugin.Declare to honor the documented default pipeline priority when a provided priority value is non-numeric, preventing silent fallback to 0 and improving operator visibility via logging.

Changes:

  • Reset prInt to the documented default (10) when strconv.Atoi fails while parsing pipeline priority.
  • Augment the error log to include the selected fallback priority value.
  • Clarify the inline comment to reflect the intended default-on-parse-error behavior.

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

Comment thread plugin.go Outdated
Comment on lines +557 to +562
// save priority as int64; fall back to the documented default on parse error.
pr := pipeline.String(priority, "10")
prInt, err := strconv.Atoi(pr)
if err != nil {
// we can continue with a default priority
p.log.Error(priority, "error", err)
p.log.Error(priority, "error", err, "fallback", 10)
prInt = 10
@rustatian rustatian changed the title fix: honor documented default priority when Atoi fails in Declare feat: migrate to Connect-RPC; new wire path /jobs.v2.JobsService/ May 10, 2026
@rustatian rustatian self-assigned this May 10, 2026
@rustatian rustatian added the enhancement New feature or request label May 10, 2026
- pipeline.String fallback now formats defaultPriority instead of "10"
- log "fallback" field uses defaultPriority directly
- reset on Atoi failure uses defaultPriority

Also switches strconv.Atoi → ParseInt to drop the redundant int64 cast,
matching the int64 type defaultPriority is declared as and the int64 the
pipeline ultimately stores.
@rustatian rustatian merged commit e100864 into master May 10, 2026
5 of 6 checks passed
@github-project-automation github-project-automation Bot moved this to ✅ Done in Jira 😄 May 10, 2026
@rustatian rustatian deleted the fix-declare-priority-default branch May 10, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants