Skip to content

Commit ffa405c

Browse files
committed
Sync documentation of main branch
1 parent d7aafbd commit ffa405c

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

_data/versioned/main/index/quarkus.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ types:
236236
- title: Security vulnerability detection and reporting in Quarkus
237237
filename: security-vulnerability-detection.adoc
238238
summary: Most of the Quarkus tags are registered in the US National Vulnerability Database (NVD) in Common Platform Enumeration (CPE) name format.
239-
categories: "security, contributing"
239+
categories: "contributing, security"
240240
id: security-vulnerability-detection
241241
type: concepts
242242
url: /guides/security-vulnerability-detection
@@ -273,7 +273,7 @@ types:
273273
- title: Building a Native Executable
274274
filename: building-native-image.adoc
275275
summary: Build native executables with GraalVM or Mandrel.
276-
categories: "native, getting-started"
276+
categories: "getting-started, native"
277277
type: tutorial
278278
url: /guides/building-native-image
279279
- title: Collect metrics using Micrometer
@@ -394,7 +394,7 @@ types:
394394
- title: AppCDS
395395
filename: appcds.adoc
396396
summary: This reference guide explains how to enable AppCDS with Quarkus.
397-
categories: "cloud, core"
397+
categories: "core, cloud"
398398
type: guide
399399
url: /guides/appcds
400400
- title: Application Data Caching
@@ -528,7 +528,7 @@ types:
528528
- title: Deploying on OpenShift
529529
filename: deploying-to-openshift.adoc
530530
summary: This guide covers how to deploy a native application on OpenShift.
531-
categories: "cloud, native"
531+
categories: "native, cloud"
532532
id: deploy-openshift
533533
type: guide
534534
url: /guides/deploying-to-openshift
@@ -813,7 +813,7 @@ types:
813813
- title: Kubernetes extension
814814
filename: deploying-to-kubernetes.adoc
815815
summary: This guide covers how to deploy a native application on Kubernetes.
816-
categories: "cloud, native"
816+
categories: "native, cloud"
817817
id: deploy-kubernetes
818818
type: guide
819819
url: /guides/deploying-to-kubernetes
@@ -1057,7 +1057,7 @@ types:
10571057
- title: SmallRye Fault Tolerance
10581058
filename: smallrye-fault-tolerance.adoc
10591059
summary: This guide demonstrates how your Quarkus application can utilize the SmallRye Fault Tolerance specification through the SmallRye Fault Tolerance extension.
1060-
categories: "web, observability"
1060+
categories: "observability, web"
10611061
type: guide
10621062
url: /guides/smallrye-fault-tolerance
10631063
- title: SmallRye GraphQL
@@ -1087,7 +1087,7 @@ types:
10871087
- title: Testing Your Application
10881088
filename: getting-started-testing.adoc
10891089
summary: "This guide covers testing in JVM mode, native mode, and injection of resources into tests"
1090-
categories: "native, core, tooling"
1090+
categories: "native, tooling, core"
10911091
id: testing
10921092
type: guide
10931093
url: /guides/getting-started-testing

_versions/main/guides/vertx-reference.adoc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,52 @@ On macOS Sierra and above you can enable the following socket options:
10081008
quarkus.http.so-reuse-port=true
10091009
----
10101010

1011+
== Use a Vert.x context-aware scheduler
1012+
1013+
Some Mutiny operators need to schedule work on an executor thread pool.
1014+
A good example is `.onItem().delayIt().by(Duration.ofMillis(10)` as it needs such an executor to delay emissions.
1015+
1016+
The default executor is returned by `io.smallrye.mutiny.infrastructure.Infrastructure` and it is already configured and managed by Quarkus.
1017+
1018+
That being said, there are cases where you need to make sure that an operation is run on a Vert.x (duplicated) context and not just on any random thread.
1019+
1020+
The `io.smallrye.mutiny.vertx.core.ContextAwareScheduler` interface offers an API to obtain context-aware schedulers.
1021+
Such a scheduler is configured with:
1022+
1023+
1. a delegate `ScheduledExecutorService` of your choice (hint: you can reuse `Infrastructure.getDefaultWorkerPool()`), and
1024+
2. a context fetching strategy among:
1025+
- an explicit `Context`, or
1026+
- calling `Vertx::getOrCreateContext()` either on the current thread or later when the scheduling request happens, or
1027+
- calling `Vertx::currentContext()`, which fails if the current thread is not a Vert.x thread.
1028+
1029+
Here is a sample where `ContextAwareScheduler` is used:
1030+
1031+
[source,java]
1032+
----
1033+
class MyVerticle extends AbstractVerticle {
1034+
1035+
@Override
1036+
public Uni<Void> asyncStart() {
1037+
vertx.getOrCreateContext().put("foo", "bar");
1038+
1039+
var delegate = Infrastructure.getDefaultWorkerPool();
1040+
var scheduler = ContextAwareScheduler.delegatingTo(delegate)
1041+
.withCurrentContext();
1042+
1043+
return Uni.createFrom().voidItem()
1044+
.onItem().delayIt().onExecutor(scheduler).by(Duration.ofMillis(10))
1045+
.onItem().invoke(() -> {
1046+
// Prints "bar"
1047+
var ctx = vertx.getOrCreateContext();
1048+
System.out.println(ctx.get("foo"));
1049+
});
1050+
}
1051+
}
1052+
----
1053+
1054+
In this example a scheduler is created by capturing the context of the Vert.x event-loop that calls `asyncStart()`.
1055+
The `delayIt` operator uses that scheduler, and we can check that the context that we get in `invoke` is a Vert.x duplicated context where the data for key `"foo"` has been propagated.
1056+
10111057
== Use a Unix domain socket
10121058

10131059
Listening on a Unix domain socket allows us to dispense with the overhead of TCP

0 commit comments

Comments
 (0)