Skip to content
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

Add Log Messages when Configuring Reactor Netty ConnectionProvider #32826

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ public com.azure.core.http.HttpClient build() {
*/
public NettyAsyncHttpClientBuilder connectionProvider(ConnectionProvider connectionProvider) {
// Enables overriding the default reactor-netty connection/channel pool.
if (connectionProvider != null) {
LOGGER.verbose("Setting ConnectionProvider for the Reactor Netty HttpClient. Please be aware of the "
+ "differences in runtime behavior when creating a default Reactor Netty HttpClient vs an HttpClient"
+ "with a specified ConnectionProvider. For more details see "
+ "https://aka.ms/azsdk/java/docs/configure-httpclient.");
}

this.connectionProvider = connectionProvider;
return this;
}

NettyAsyncHttpClientBuilder connectionProviderInternal(ConnectionProvider connectionProvider) {
this.connectionProvider = connectionProvider;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.azure.core.http.HttpClientProvider;
import com.azure.core.util.Configuration;
import com.azure.core.util.HttpClientOptions;
import com.azure.core.util.logging.ClientLogger;
import reactor.netty.resources.ConnectionProvider;

/**
Expand All @@ -18,6 +19,8 @@ public final class NettyAsyncHttpClientProvider implements HttpClientProvider {
private final boolean enableHttpClientSharing;
private static final int DEFAULT_MAX_CONNECTIONS = 500;

private static final ClientLogger LOGGER = new ClientLogger(NettyAsyncHttpClientProvider.class);

// Enum Singleton Pattern
private enum GlobalNettyHttpClient {
HTTP_CLIENT(new NettyAsyncHttpClientBuilder().build());
Expand Down Expand Up @@ -73,6 +76,8 @@ public HttpClient createInstance(HttpClientOptions clientOptions) {
// Only configure the maximum connections if it has been set in the options.
Integer maximumConnectionPoolSize = clientOptions.getMaximumConnectionPoolSize();
if (maximumConnectionPoolSize != null && maximumConnectionPoolSize > 0) {
LOGGER.verbose("Setting Reactor Netty ConnectionProvider's maximum connections to "
+ maximumConnectionPoolSize + ".");
connectionProviderBuilder.maxConnections(maximumConnectionPoolSize);
} else {
// reactor-netty (as of version 1.0.13) uses different default values for maxConnections when creating
Expand All @@ -89,7 +94,7 @@ public HttpClient createInstance(HttpClientOptions clientOptions) {
connectionProviderBuilder.maxConnections(DEFAULT_MAX_CONNECTIONS);
}

builder = builder.connectionProvider(connectionProviderBuilder.build());
builder = builder.connectionProviderInternal(connectionProviderBuilder.build());

return builder.build();
}
Expand Down