Skip to content

Commit

Permalink
Update reference documentation for event loop group (#2952)
Browse files Browse the repository at this point in the history
Related to #2943 (comment)
  • Loading branch information
violetagg committed Oct 31, 2023
1 parent 4aad8a3 commit e27921e
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 104 deletions.
28 changes: 28 additions & 0 deletions docs/asciidoc/eventloop.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
:eventloopsourcedir: ./../../reactor-netty-core/src/main/java

=== Event Loop Group

By default `Reactor Netty` uses an "`Event Loop Group`", where the number of the worker threads equals the number of
processors available to the runtime on initialization (but with a minimum value of 4). When you need a different configuration,
you can use one of the {javadoc}/reactor/netty/resources/LoopResources.html[`LoopResource`]`#create`
methods.

The following listing shows the default configuration for the Event Loop Group:

====
[source,java,indent=0]
.{eventloopsourcedir}/reactor/netty/ReactorNetty.java
----
include::{eventloopsourcedir}/reactor/netty/ReactorNetty.java[lines=86..120]
----
====

If you need changes to these settings, you can apply the following configuration:

====
[source,java,indent=0]
.{examplesdir}/eventloop/Application.java
----
include::{examplesdir}/eventloop/Application.java[lines=18..38]
----
====
2 changes: 2 additions & 0 deletions docs/asciidoc/http-client.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ See <<tcp-client>> for more about `TCP` level configurations.

include::wire-logger.adoc[]

include::eventloop.adoc[]

include::http-client-conn-provider.adoc[]

== SSL and TLS
Expand Down
2 changes: 2 additions & 0 deletions docs/asciidoc/http-server.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ See <<tcp-server>> for more detail about TCP-level configuration.

include::wire-logger.adoc[]

include::eventloop.adoc[]

== SSL and TLS

When you need SSL or TLS, you can apply the configuration shown in the next example.
Expand Down
27 changes: 1 addition & 26 deletions docs/asciidoc/tcp-client.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -204,32 +204,7 @@ You can find more about `Netty` channel options at the following links:
include::wire-logger.adoc[]

[[client-tcp-level-configurations-event-loop-group]]
=== Event Loop Group

By default the `TCP` client uses an "`Event Loop Group`", where the number of the worker threads equals the number of
processors available to the runtime on initialization (but with a minimum value of 4). When you need a different configuration,
you can use one of the {javadoc}/reactor/netty/resources/LoopResources.html[LoopResource]`#create`
methods.

The following listing shows the default configuration for the Event Loop Group:

====
[source,java,indent=0]
.{sourcedir}/reactor/netty/ReactorNetty.java
----
include::{sourcedir}/reactor/netty/ReactorNetty.java[lines=86..120]
----
====

If you need changes to the these settings, you can apply the following configuration:

====
[source,java,indent=0]
.{examplesdir}/eventloop/Application.java
----
include::{examplesdir}/eventloop/Application.java[lines=18..37]
----
====
include::eventloop.adoc[]

include::tcp-client-conn-provider.adoc[]

Expand Down
27 changes: 1 addition & 26 deletions docs/asciidoc/tcp-server.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -182,32 +182,7 @@ You can find more about `Netty` channel options at the following links:
include::wire-logger.adoc[]

[[server-tcp-level-configurations-event-loop-group]]
=== Event Loop Group

By default, the `TCP` server uses an "`Event Loop Group,`" where the number of the worker threads equals the number of
processors available to the runtime on initialization (but with a minimum value of 4). When you need a different configuration,
you can use one of the {javadoc}/reactor/netty/resources/LoopResources.html[LoopResource]`#create`
methods.

The default configuration for the `Event Loop Group` is the following:

====
[source,java,indent=0]
.{sourcedir}/reactor/netty/ReactorNetty.java
----
include::{sourcedir}/reactor/netty/ReactorNetty.java[lines=86..120]
----
====

If changes to the these settings are needed, you can apply the following configuration:

====
[source,java,indent=0]
.{examplesdir}/eventloop/Application.java
----
include::{examplesdir}/eventloop/Application.java[lines=18..35]
----
====
include::eventloop.adoc[]

== SSL and TLS

Expand Down
27 changes: 1 addition & 26 deletions docs/asciidoc/udp-client.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -172,32 +172,7 @@ You can find more about Netty channel options at the following links:
include::wire-logger.adoc[]

[[client-udp-connection-configurations-event-loop-group]]
=== Event Loop Group

By default, the UDP client uses "`Event Loop Group,`" where the number of the worker threads equals the number of
processors available to the runtime on initialization (but with a minimum value of 4). When you need a different configuration,
you can use one of the {javadoc}/reactor/netty/resources/LoopResources.html[`LoopResources`]`#create`
methods.

The following listing shows the default configuration for the "`Event Loop Group`":

====
[source,java,indent=0]
.{sourcedir}/reactor/netty/ReactorNetty.java
----
include::{sourcedir}/reactor/netty/ReactorNetty.java[lines=86..120]
----
====

If you need changes to the these settings, you can apply the following configuration:

====
[source,java,indent=0]
.{examplesdir}/eventloop/Application.java
----
include::{examplesdir}/eventloop/Application.java[lines=18..38]
----
====
include::eventloop.adoc[]

== Metrics
The UDP client supports built-in integration with https://micrometer.io/[`Micrometer`].
Expand Down
27 changes: 1 addition & 26 deletions docs/asciidoc/udp-server.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -166,32 +166,7 @@ For more information about Netty channel options, see the following links:
include::wire-logger.adoc[]

[[server-udp-connection-configurations-event-loop-group]]
=== Event Loop Group

By default, the UDP server uses "`Event Loop Group,`" where the number of the worker threads equals the number of
processors available to the runtime on initialization (but with a minimum value of 4). When you need a different configuration,
you can use one of the {javadoc}/reactor/netty/resources/LoopResources.html[LoopResource]`#create`
methods.

The default configuration for the "`Event Loop Group`" is the following:

====
[source,java,indent=0]
.{sourcedir}/reactor/netty/ReactorNetty.java
----
include::{sourcedir}/reactor/netty/ReactorNetty.java[lines=86..120]
----
====

If you need changes to these settings, you can apply the following configuration:

====
[source,java,indent=0]
.{examplesdir}/eventloop/Application.java
----
include::{examplesdir}/eventloop/Application.java[lines=18..36]
----
====
include::eventloop.adoc[]

== Metrics
The UDP server supports built-in integration with https://micrometer.io/[`Micrometer`].
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2023 VMware, Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package reactor.netty.examples.documentation.http.client.eventloop;

import reactor.netty.http.client.HttpClient;
import reactor.netty.resources.LoopResources;

public class Application {

public static void main(String[] args) {
LoopResources loop = LoopResources.create("event-loop", 1, 4, true);
HttpClient client =
HttpClient.create()
.runOn(loop);

client.get()
.uri("https://example.com/")
.responseContent()
.aggregate()
.asString()
.block();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 VMware, Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package reactor.netty.examples.documentation.http.server.eventloop;

import reactor.netty.DisposableServer;
import reactor.netty.http.server.HttpServer;
import reactor.netty.resources.LoopResources;

public class Application {

public static void main(String[] args) {
LoopResources loop = LoopResources.create("event-loop", 1, 4, true);

DisposableServer server =
HttpServer.create()
.runOn(loop)
.bindNow();

server.onDispose()
.block();
}
}

0 comments on commit e27921e

Please sign in to comment.