-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add AsyncTransportSettings, ExecutorService #1489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
771ea89
Add AsyncTransportSettings, ExecutorService
katcharov b9cd758
Apply suggestions from code review
katcharov 14b9fee
PR fixes
katcharov 7fcbbee
PR fixes
katcharov 2b717cc
Apply suggestions from code review
katcharov 6491f2f
PR fixes
katcharov f3126b2
Merge branch 'main' into JAVA-5505
katcharov 9f3d8a9
PR fixes
katcharov e144364
PR fix
katcharov 43c2f94
Update driver-reactive-streams/src/test/functional/com/mongodb/reacti…
katcharov e373347
PR fix
katcharov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
driver-core/src/main/com/mongodb/connection/AsyncTransportSettings.java
This file contains hidden or 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,98 @@ | ||
/* | ||
* Copyright 2008-present MongoDB, Inc. | ||
* | ||
* 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 | ||
* | ||
* http://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 com.mongodb.connection; | ||
|
||
import com.mongodb.lang.Nullable; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
|
||
import static com.mongodb.assertions.Assertions.notNull; | ||
|
||
/** | ||
* {@link TransportSettings} for a non-<a href="http://netty.io/">Netty</a>-based async transport implementation. | ||
* Shallowly immutable. | ||
* | ||
* @since 5.2 | ||
*/ | ||
public final class AsyncTransportSettings extends TransportSettings { | ||
|
||
private final ExecutorService executorService; | ||
|
||
private AsyncTransportSettings(final Builder builder) { | ||
this.executorService = builder.executorService; | ||
} | ||
|
||
static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
/** | ||
* A builder for an instance of {@link AsyncTransportSettings} | ||
*/ | ||
public static final class Builder { | ||
|
||
private ExecutorService executorService; | ||
|
||
private Builder() { | ||
} | ||
|
||
/** | ||
* The executor service, intended to be used exclusively by the mongo | ||
* client. Closing the mongo client will result in {@linkplain ExecutorService#shutdown() orderly shutdown} | ||
* of the executor service. | ||
* | ||
* <p>When {@linkplain SslSettings#isEnabled() TLS is not enabled}, see | ||
* {@link java.nio.channels.AsynchronousChannelGroup#withThreadPool(ExecutorService)} | ||
* for additional requirements for the executor service. | ||
* | ||
* @param executorService the executor service | ||
* @return this | ||
* @see #getExecutorService() | ||
*/ | ||
public Builder executorService(final ExecutorService executorService) { | ||
stIncMale marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this.executorService = notNull("executorService", executorService); | ||
return this; | ||
} | ||
|
||
/** | ||
* Build an instance of {@link AsyncTransportSettings} | ||
* @return an instance of {@link AsyncTransportSettings} | ||
*/ | ||
public AsyncTransportSettings build() { | ||
return new AsyncTransportSettings(this); | ||
} | ||
} | ||
|
||
/** | ||
* Gets the executor service | ||
* | ||
* @return the executor service | ||
* @see Builder#executorService(ExecutorService) | ||
*/ | ||
@Nullable | ||
public ExecutorService getExecutorService() { | ||
return executorService; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "AsyncTransportSettings{" | ||
+ "executorService=" + executorService | ||
+ '}'; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.