Skip to content

Commit

Permalink
Add ability to always require a socket
Browse files Browse the repository at this point in the history
I have a use case the combines both virtual dispatch and standard HTTP, this lets extensions support both.

(cherry picked from commit 6750fe6)
  • Loading branch information
stuartwdouglas authored and gsmet committed Aug 6, 2024
1 parent ebcc9c7 commit 2109207
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.quarkus.vertx.http.deployment;

import io.quarkus.builder.item.SimpleBuildItem;

/**
* Marker class that can be used to force the socket to open even when using virtual HTTP.
*
* There are some use cases that may want to handle both real and virtual HTTP requests, such as mapping incoming
* gRPC requests onto JAX-RS handlers.
*/
public final class RequireSocketHttpBuildItem extends SimpleBuildItem {
public static final RequireSocketHttpBuildItem MARKER = new RequireSocketHttpBuildItem();
}
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ void openSocket(ApplicationStartBuildItem start,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
HttpBuildTimeConfig httpBuildTimeConfig,
Optional<RequireVirtualHttpBuildItem> requireVirtual,
Optional<RequireSocketHttpBuildItem> requireSocket,
EventLoopCountBuildItem eventLoopCount,
List<WebsocketSubProtocolsBuildItem> websocketSubProtocols,
Capabilities capabilities,
Expand All @@ -430,8 +431,9 @@ void openSocket(ApplicationStartBuildItem start,
.produce(ReflectiveClassBuildItem.builder(VirtualServerChannel.class)
.build());
}
boolean startSocket = (!startVirtual || launchMode.getLaunchMode() != LaunchMode.NORMAL)
&& (requireVirtual.isEmpty() || !requireVirtual.get().isAlwaysVirtual());
boolean startSocket = requireSocket.isPresent() ||
((!startVirtual || launchMode.getLaunchMode() != LaunchMode.NORMAL)
&& (requireVirtual.isEmpty() || !requireVirtual.get().isAlwaysVirtual()));
recorder.startServer(vertx.getVertx(), shutdown,
launchMode.getLaunchMode(), startVirtual, startSocket,
eventLoopCount.getEventLoopCount(),
Expand Down

0 comments on commit 2109207

Please sign in to comment.