Skip to content

Commit

Permalink
Improve VertxBuilder documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Nov 26, 2024
1 parent 13952f8 commit cfd1d0b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 12 additions & 2 deletions vertx-core/src/main/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -794,9 +794,19 @@ If you are using Vert.x from a Maven or Gradle project just add the cluster mana

For more information on this, please consult https://vertx.io/docs/#clustering

=== Programmatic SPI selection and configuration
== Vert.x Builder

The {@link io.vertx.core.VertxBuilder} gives you more control over the SPI selection and configuration.
{@link io.vertx.core.Vertx#vertx()} and {@link io.vertx.core.Vertx#clusteredVertx(io.vertx.core.VertxOptions)} static
methods are the easiest way obtain an instance of {@link io.vertx.core.Vertx}.

You can also use the https://en.wikipedia.org/wiki/Builder_pattern[builder pattern] to create a `Vertx` instance. The builder
lets you programmatically configure a few providers (SPI) which are usually loaded using `VertxOptions` and/or Java
Service Loader plugins.

- Native <<_native_transports, transport>>
- Cluster manager
- Tracing
- Metrics instance

[source,$lang]
----
Expand Down
4 changes: 3 additions & 1 deletion vertx-core/src/main/java/examples/CoreExamples.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.vertx.core.net.NetServer;
import io.vertx.core.net.SocketAddress;
import io.vertx.core.spi.VertxMetricsFactory;
import io.vertx.core.spi.VertxTracerFactory;
import io.vertx.core.spi.cluster.ClusterManager;
import io.vertx.core.transport.Transport;

Expand Down Expand Up @@ -111,9 +112,10 @@ String blockingMethod(String str) {
}
}

public void vertxBuilder(VertxOptions options, VertxMetricsFactory metricsFactory) {
public void vertxBuilder(VertxOptions options, VertxMetricsFactory metricsFactory, VertxTracerFactory tracerFactory) {
Vertx vertx = Vertx.builder()
.with(options)
.withTracer(tracerFactory)
.withMetrics(metricsFactory)
.build();
}
Expand Down

0 comments on commit cfd1d0b

Please sign in to comment.