Commit fbac6ab
committed
Add quarkus-smithy extension and Smithy Vert.x server
Smithy services run inside Quarkus applications via a new extension that
mounts every CDI-discovered Service bean on Quarkus's main HTTP router.
Smithy operations share the Quarkus HTTP server's port — no separate
Smithy listener.
## Customer-facing surface
Users produce a `@Produces Service` bean (the generated service stub):
@ApplicationScoped
public class CoffeeShopServerConfig {
@produces @singleton
Service coffeeShop() {
return CoffeeShop.builder()
.addCreateOrderOperation(new CreateOrder())
.addGetMenuOperation(new GetMenu())
.addGetOrderOperation(new GetOrder())
.build();
}
}
The extension mounts a `SmithyVertxServer` on Quarkus's `Router` as a
single catch-all route. Per-request, a `ProtocolResolver` iterates a
precision-ordered list of `ServerProtocol`s and returns one of three
outcomes:
- claim -> dispatch to the operation
- no-claim -> ctx.next() (delegate to a sibling handler)
- claim-and-reject -> 404 directly (request is Smithy's but malformed)
This implements the Smithy 2.0 Wire-protocol-selection guide.
End-to-end CoffeeShop example at `examples/quarkus-server/`. Standalone
Gradle build that consumes smithy-java via mavenLocal — required because
including it as a subproject causes Quarkus dev-mode workspace discovery
to substitute sibling raw `build/classes` for the published jars,
splitting classloaders in ways that break `:codecs:json-codec`'s
shadowJar.
## Modules
- `:server:server-vertx` — `SmithyVertxServer implements
Handler<RoutingContext>`, `ServerOptions`, `VertxRequestHeaders`.
18 integration tests against a real Vert.x HTTP server.
- `:quarkus-smithy` (runtime) — `SmithyVertxRecorder` and
`SmithyServerConfig` (`@ConfigMapping` for
`quarkus.smithy.server.{path-prefix, workers, shutdown-grace}`).
The recorder collects `Service` beans from Arc, walks
TCCL+own-loader for `ServerProtocolProvider`s (required because
`ProtocolResolver`'s static SPI cache can't see runtime jars under
`QuarkusClassLoader`), constructs the server, mounts it on the
main router, and registers ordered shutdown tasks.
- `:quarkus-smithy-deployment` (build-time) — `SmithyProcessor`
`@BuildStep`s and `SmithyCodeGenProvider` that hooks Smithy
code generation into `quarkusGenerateCode` (no `smithy-base`
Gradle plugin needed).
- `:quarkus-smithy-integration-tests` — `SmithyCodeGenProviderTest`.
## Cross-module changes
- `:server:server-core`
- `ProtocolResolver` gains `resolveOrEmpty(...)` returning
`Optional<ServiceProtocolResolutionResult>` and a second ctor
accepting a pre-loaded protocol list (for callers like the
Quarkus recorder where the static SPI cache is blind).
- `HttpResponseSerializer` is new: status + header-copy +
content-type/length logic shared between Netty and the Vert.x
server. Body exposed as the underlying `DataStream` so Netty
preserves zero-copy via `Unpooled.wrappedBuffer(ByteBuffer)`.
- `ServerProtocolProvider.precision()` Javadoc documents the AWS
service-protocol scale (rpcv2Cbor=1 ... restXml=8).
- `:server:server-netty` — `HttpRequestHandler.writeResponse` adopts
`HttpResponseSerializer`. Behavior unchanged.
- Provider precision values: `RpcV2CborProtocolProvider` -> 1,
`RpcV2JsonProtocolProvider` -> 2, `AwsRestJson1ProtocolProvider`
-> 7. Previously all 0 (precision sort was a no-op against
classpath order).
- `:aws:server:aws-server-restjson` — drops dead `routes` field and
`smithyToVertxPath` helper (the Vert.x server no longer enumerates
per-operation routes).
## Verification
- `./gradlew :server:server-vertx:check` green. 19 integration tests
against a real Vert.x HTTP server: protocol resolution outcomes,
HTTP/2 round-trip, lifecycle, options, precision regression.
- `./gradlew :server:server-core:check` green. New tests:
`HttpResponseSerializerTest` (6) and `ProtocolResolverTest` (7).
- `./gradlew :quarkus-smithy:build :quarkus-smithy-deployment:build`
green (with `--no-configuration-cache` to work around a pre-existing
Quarkus extension-validation gradle-plugin issue).
- `examples/quarkus-server` end-to-end (`quarkusDev`):
`GET /menu`, `PUT /order`, `GET /order/<id>` all 200 under
restJson1; CoffeeShop also reachable via `POST
/service/CoffeeShop/operation/<Op>` with `smithy-protocol:
rpc-v2-cbor` and `smithy-protocol: rpc-v2-json` headers; rpcv2
path with no header -> Quarkus default 404 via ctx.next(); rpcv2
path with header but malformed URI -> server 404 with empty body
(claim-and-reject). The empty-body 404 vs Quarkus's default-page
404 confirms the resolution-outcome distinctions are observable.
## Known limitations (deferred)
- `@streaming Blob` operations not supported. The recorder installs
Vert.x's `BodyHandler` upstream of the server, fully buffering
request bodies before resolution runs.
- Native-image support is out of scope for this cut.
- CORS support on the Vert.x server (Netty has it).
- Cross-service `@http(uri)` collisions are silent at construction
time — the matcher's tie-break wins.1 parent 7809638 commit fbac6ab
52 files changed
Lines changed: 4631 additions & 19 deletions
File tree
- aws/server/aws-server-restjson/src/main/java/software/amazon/smithy/java/aws/server/restjson
- examples/quarkus-server
- gradle/wrapper
- src/main
- java/software/amazon/smithy/java/example/quarkus
- resources
- smithy
- gradle
- quarkus-smithy-deployment
- src/main
- java/software/amazon/smithy/java/quarkus/deployment
- resources/META-INF/services
- quarkus-smithy-integration-tests
- src/test/java/software/amazon/smithy/java/quarkus/integration
- quarkus-smithy
- src/main/java/software/amazon/smithy/java/quarkus/runtime
- server
- server-core/src
- main/java/software/amazon/smithy/java/server/core
- test/java/software/amazon/smithy/java/server/core
- server-netty/src/main/java/software/amazon/smithy/java/server/netty
- server-rpcv2-cbor/src/main/java/software/amazon/smithy/java/server/rpcv2
- server-rpcv2-json/src/main/java/software/amazon/smithy/java/server/rpcv2json
- server-vertx
- src
- main/java/software/amazon/smithy/java/server/vertx
- test/java/software/amazon/smithy/java/server/vertx
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
Binary file not shown.
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments