Skip to content

feature: Add @RPC scripted test + extend Object filter (#498 Gap 4 Part 2)#503

Merged
xerial merged 1 commit into
mainfrom
feature/rpc-codegen-test
Apr 26, 2026
Merged

feature: Add @RPC scripted test + extend Object filter (#498 Gap 4 Part 2)#503
xerial merged 1 commit into
mainfrom
feature/rpc-codegen-test

Conversation

@xerial
Copy link
Copy Markdown
Member

@xerial xerial commented Apr 26, 2026

Summary

Wraps up #498 Gap 4. The runtime API surface (`@RPC`, `RxRouter`,
`RxRouterProvider`) landed in #501 and the existing `uniHttpClients`
codegen pipeline (`HttpCodeGenerator` + `ServiceScanner`) already
produces the same `POST` routes that an `@RPC`-annotated trait expects.
This PR adds the missing test + polish:

  • A second sbt-uni scripted test (`codegen/rpc-client-annotated`) that
    drives codegen against an `@RPC`-annotated trait whose companion
    extends `RxRouterProvider` — the exact migration shape used by
    wvlet-api's `FrontendApi`. Verifies end-to-end that the annotation
    doesn't break the codegen pipeline and that the generated client
    class compiles.
  • Extends `ObjectMethodNames` in `RouterMacros` to also exclude
    `scala.Product` members (`canEqual`, `productArity`, `productElement`,
    `productElementName`, `productIterator`, `productPrefix`).
    `Surface.methodsOf` already filters them by owner; this is
    belt-and-suspenders, addressing Gemini's medium-priority follow-up
    on fix: Filter Object methods and prefix StemNode names (#501 follow-up) #502.
  • Mirrors the same Product-method exclusion in `ServiceScanner`'s
    `excludedNames` so codegen output stays consistent with router output
    when applied to case-class-flavored services.

Why this closes Gap 4

Issue #498 Gap 4 lists three deliverables:

  1. `@RPC` annotation — landed in feature: Add @RPC, RxRouter, and RxRouterProvider (#498 Gap 4 Part 1) #501.
  2. `RxRouter` API in `wvlet.uni.http.router` — landed in feature: Add @RPC, RxRouter, and RxRouterProvider (#498 Gap 4 Part 1) #501.
  3. `sbt-uni` codegen task equivalent to `airframeHttpClients` —
    already present as `uniHttpClients` (`UniPlugin.scala`), which the
    new scripted test exercises against an `@RPC` trait.

After this PR merges, wvlet-api's `FrontendApi` / `FileApi`-style
`@RPC` trait + `RxRouterProvider` companion shape compiles against
uni and `uniHttpClients` generates the typed RPC client.

Test plan

  • `uniJVM/testOnly wvlet.uni.http.router.RxRouterTest` — 10 tests pass
  • `sbt plugin scripted test` runs `codegen/rpc-client` (existing
    backward-compat coverage) and `codegen/rpc-client-annotated`
    (new `@RPC` coverage) in the same CI step.

Refs #498 Gap 4 Part 2 (final).

…rt 2)

Wraps up #498 Gap 4. The runtime API surface (@rpc, RxRouter,
RxRouterProvider) landed in #501, and the existing uniHttpClients
codegen pipeline (HttpCodeGenerator + ServiceScanner) already produces
the same POST routes that an @RPC-annotated trait expects. This PR adds:

- A second sbt-uni scripted test (codegen/rpc-client-annotated) that
  drives codegen against an @RPC-annotated trait whose companion
  extends RxRouterProvider — the exact migration shape used by
  wvlet-api's FrontendApi. Verifies end-to-end that the annotation
  doesn't break the codegen pipeline and that the generated client
  class compiles.
- Extends ObjectMethodNames in RouterMacros to also exclude
  scala.Product members (canEqual, productArity, productElement,
  productElementName, productIterator, productPrefix). Surface.methodsOf
  already filters them by owner; this is belt-and-suspenders, addressing
  Gemini's medium-priority follow-up on #502.
- Mirrors the same Product-method exclusion in ServiceScanner's
  excludedNames so codegen output stays consistent with router output
  when applied to case-class-flavored services.
@xerial xerial enabled auto-merge (squash) April 26, 2026 17:18
@github-actions github-actions Bot added the feature New feature label Apr 26, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new test case to verify RPC client code generation for traits with companions extending RxRouterProvider. Additionally, it updates ServiceScanner and RouterMacros to exclude standard scala.Product methods from being identified as service routes. Feedback was provided to include productElementNames in the exclusion lists for both files to ensure complete coverage of Product methods.

Comment on lines +51 to +56
"canEqual",
"productArity",
"productElement",
"productElementName",
"productIterator",
"productPrefix",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The list of scala.Product methods is missing productElementNames. While productElementName (singular) is included, the plural version productElementNames (which returns an Iterator[String]) should also be excluded to ensure that all standard product-related methods are filtered out during service scanning.

      "canEqual",
      "productArity",
      "productElement",
      "productElementName",
      "productElementNames",
      "productIterator",
      "productPrefix",

Comment on lines +205 to +210
"canEqual",
"productArity",
"productElement",
"productElementName",
"productIterator",
"productPrefix"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The list of scala.Product methods is missing productElementNames. For consistency with the intended "belt-and-suspenders" approach to exclude all Product members, please add productElementNames to this set.

    "canEqual",
    "productArity",
    "productElement",
    "productElementName",
    "productElementNames",
    "productIterator",
    "productPrefix"

@xerial xerial merged commit 4160b58 into main Apr 26, 2026
14 checks passed
@xerial xerial deleted the feature/rpc-codegen-test branch April 26, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant