Skip to content

POC: Quarkus integration via shared transport Vert.x and Smithy Codegen extension#1205

Draft
chenliu0831 wants to merge 3 commits into
smithy-lang:mainfrom
chenliu0831:main
Draft

POC: Quarkus integration via shared transport Vert.x and Smithy Codegen extension#1205
chenliu0831 wants to merge 3 commits into
smithy-lang:mainfrom
chenliu0831:main

Conversation

@chenliu0831
Copy link
Copy Markdown

Issue #, if available: N/A, supersede #1196 since we decide to go single/unified server approach with shared transport first.

Description of changes:

⚠️ Proof of concept.

  • One ingress port. Smithy operations and Quarkus management endpoints
    (/q/health, /q/dev-ui) share the same listener.
  • HTTP/2 capability. First Smithy-Java transport to carry operations
    over HTTP/2; wire-version negotiation is delegated entirely to
    quarkus-vertx-http.
  • Multi-protocol coexistence. Routes are grouped by (method, path),
    so rpcv2-cbor + rpcv2-json sharing a path collapse into one Vert.x route
    whose dispatcher picks the protocol per request via the smithy-protocol
    header.
  • Hot reload. BoundBridge.unbind() removes every installed route
    atomically, supporting Quarkus dev-mode reloads cleanly.

Test plan

  • Protocol integration test to make sure protocol flexibility actually works.
  • :server:server-vertx-bridge:test green
  • :quarkus-smithy-integration-tests:test green
  • :aws:server:aws-server-restjson:integ green
  • rpcv2-cbor / rpcv2-json integ green
  • Standalone example: quarkusBuildjava -jar quarkus-run.jar,
    probes GET /menu, PUT /order, GET /order/:id, GET /no-such
    returning 200 / 200 / 200 / 404 with correct payloads
  • Standalone example: quarkusDev, same four probes pass; hot reload
    verified via `BoundBridge.unbind()

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

// service-level protocol trait was tried but doesn't work:
// codegen-generated services may carry no traits on the
// service schema (the protocol shows up only on operations
// and members).
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not a fan of the approach here.. need a bit more thought

Mounts Smithy operations on Quarkus's Vert.x HTTP server via a new
upstream :server:server-vertx-bridge module — no separate Smithy
listener. Replaces the experimental @produces Server shape with
@produces Service.

Upstream (smithy-java)
  * server-vertx-bridge: SmithyServiceBridge.bridge(services).bind(router)
    plus BoundBridge (unbind / shutdown) and BridgeOptions
    (path-prefix, workers, shutdown-grace). Routes are derived per
    operation; multi-protocol same-path requests (rpcv2-cbor +
    rpcv2-json on /service/X/operation/Y) collapse into one route
    that picks protocol by smithy-protocol header.
  * ServerProtocol.enumerateRoutes() + RouteSpec record. restJson1
    uses @http(method, uri); rpcv2 computes /service/<Name>/operation/<Op>
    and skips services whose operations carry @http traits (avoids
    phantom mounts).
  * server-api package promoted out of @SmithyUnstableApi; bridge
    consumers now see a stable surface.
  * BasicServiceExample under examples/end-to-end demonstrating the
    bridge against plain Vert.x (no Quarkus).

quarkus-smithy extension
  * SmithyVertxRecorder + SmithyProcessor mount the bridge on
    mainRouter at RUNTIME_INIT, register unbind/shutdown tasks, and
    short-circuit silently when no @produces Service beans exist
    (ADR-0006 OQ7).
  * SmithyServerConfig (@ConfigMapping prefix=quarkus.smithy.server)
    exposes path-prefix, workers, shutdown-grace.
  * UnremovableBeanBuildItem retains user @produces Service beans.

examples/quarkus-server (canonical example)
  * Standalone Gradle build (its own gradlew) that consumes
    smithy-java only via mavenLocal — required because Quarkus
    workspace discovery would otherwise substitute sibling raw
    build/classes for json-codec's shaded jar and split the
    classloader graph.
  * Service-bean producer for CoffeeShop; full Dev & Test guide in
    README (boot, curl probes, hot reload, path-prefix, packaged
    jar, Dev UI, integration tests).

Cleanup
  * Delete examples/quarkus-types and examples/quarkus-client. The
    extension is server-only today; Typed-client and Types-only are
    documented as future directions in README.md and CONTEXT.md but
    no longer ship as supported user-facing programming models.
  * Delete the experimental SmithyServerLifecycle observer
    (@produces Server path).
  * Drop the implementation-plan doc; ADR-0006 §Implementation is
    now the canonical record.
  * settings.gradle.kts no longer includes :examples:quarkus-{server,
    client,types} (server is intentionally standalone).

Verification
  * :server:server-vertx-bridge:test 16/16
  * :quarkus-smithy-integration-tests:test green
  * :aws:server:aws-server-restjson:integ + rpcv2 integ green
  * Prod jar smoke (java -jar quarkus-run.jar): GET /menu 200,
    PUT /order 200, GET /order/:id 200, GET /no-such 404 with
    correct payloads
  * Dev mode (quarkusDev): same four probes pass; hot reload works
    via BoundBridge.unbind()
@chenliu0831
Copy link
Copy Markdown
Author

Looks like there might be major flaw with the multi Vert.x routes mount approach which violate https://smithy.io/2.0/guides/wire-protocol-selection.html after chatting with Adwait. Doing another iteration...

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