-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update reference documentation for event loop group (#2952)
Related to #2943 (comment)
- Loading branch information
Showing
9 changed files
with
107 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
---- | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...src/main/java/reactor/netty/examples/documentation/http/client/eventloop/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...src/main/java/reactor/netty/examples/documentation/http/server/eventloop/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |