Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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 @@ -915,7 +915,7 @@ public static class ConnectionPoolConfiguration implements Toggleable {
private int maxPendingConnections = 4;

private int maxConcurrentRequestsPerHttp2Connection = Integer.MAX_VALUE;
private int maxConcurrentHttp1Connections = Integer.MAX_VALUE;
private int maxConcurrentHttp1Connections = 1000;
private int maxConcurrentHttp2Connections = 1;

private int maxPendingAcquires = Integer.MAX_VALUE;
Expand All @@ -927,6 +927,9 @@ public static class ConnectionPoolConfiguration implements Toggleable {
@NonNull
private HttpClientConfiguration.ConnectionPoolConfiguration.ConnectionLocality connectionLocality = ConnectionLocality.PREFERRED;

@NonNull
private PoolVersion version = PoolVersion.V4_9;

/**
* Whether connection pooling is enabled.
* [available in the Netty HTTP client]
Expand Down Expand Up @@ -1088,6 +1091,26 @@ public void setConnectionLocality(@NonNull HttpClientConfiguration.ConnectionPoo
this.connectionLocality = connectionLocality;
}

/**
* The version of the connection pool implementation. Defaults to {@code V4_9}, can be set
* to {@code V4_0} for compatibility.
*
* @return The pool version
*/
public @NonNull PoolVersion getVersion() {
return version;
}

/**
* The version of the connection pool implementation. Defaults to {@code V4_9}, can be set
* to {@code V4_0} for compatibility.
*
* @param version The pool version
*/
public void setVersion(@NonNull PoolVersion version) {
this.version = version;
}

/**
* Options for {@link #connectionLocality}.
*
Expand Down Expand Up @@ -1120,6 +1143,22 @@ public enum ConnectionLocality {
*/
ENFORCED_ALWAYS,
}

/**
* Different pool implementation versions, for compatibility.
*
* @since 4.9.0
*/
public enum PoolVersion {
/**
* The connection pool introduced in micronaut-core 4.0.0.
*/
V4_0,
/**
* The connection pool introduced in micronaut-core 4.9.0.
*/
V4_9
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.micronaut.http.client.loadbalance;

import io.micronaut.core.annotation.Internal;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.core.async.publisher.Publishers;
import io.micronaut.discovery.ServiceInstance;
Expand All @@ -36,6 +37,7 @@
*/
public class FixedLoadBalancer implements LoadBalancer {
private final Publisher<ServiceInstance> publisher;
private final ServiceInstance serviceInstance;
private final URI uri;

/**
Expand All @@ -56,7 +58,8 @@ public FixedLoadBalancer(URL url) {
*/
public FixedLoadBalancer(URI uri) {
this.uri = uri;
this.publisher = Publishers.just(ServiceInstance.of(uri.getHost(), uri));
serviceInstance = ServiceInstance.of(uri.getHost(), uri);
this.publisher = Publishers.just(serviceInstance);
}

@Override
Expand Down Expand Up @@ -84,6 +87,16 @@ public URI getUri() {
return uri;
}

/**
* The fixed {@link ServiceInstance} returned by {@link #select}. Internal use only.
*
* @return The service instance
*/
@Internal
public ServiceInstance getServiceInstance() {
return serviceInstance;
}

@Override
public Optional<String> getContextPath() {
return Optional.ofNullable(getUri().getPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.http.client.exceptions.HttpClientException;
import io.netty.channel.EventLoop;
import io.netty.util.concurrent.EventExecutor;

/**
* Information about what threads are blocked waiting for a request to complete. This is used to
Expand Down Expand Up @@ -64,7 +64,7 @@ static HttpClientException createException() {
"https://docs.micronaut.io/latest/guide/index.html#clientConfiguration");
}

boolean blocks(EventLoop eventLoop) {
boolean blocks(EventExecutor eventLoop) {
BlockHint bh = this;
while (bh != null) {
if (eventLoop.inEventLoop(bh.blockedThread)) {
Expand Down
Loading
Loading