package io.vertx.core.http.impl;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.net.impl.clientconnection.Pool;
import io.vertx.core.impl.ContextInternal;
import io.vertx.core.spi.metrics.ClientMetrics;
import io.vertx.core.spi.metrics.HttpClientMetrics;
class ClientHttpStreamEndpoint extends ClientHttpEndpointBase {
private final Pool<HttpClientConnection> pool;
public ClientHttpStreamEndpoint(ClientMetrics metrics,
Object metric,
int queueMaxSize,
long maxSize,
String host,
int port,
ContextInternal ctx,
HttpChannelConnector connector,
Runnable dispose) {
super(metrics, port, host, metric, dispose);
this.pool = new Pool<>(
ctx,
connector,
queueMaxSize,
connector.weight(),
maxSize,
this::connectionAdded,
this::connectionRemoved,
false);
}
void checkExpired() {
pool.closeIdle();
}
@Override
public void requestConnection2(ContextInternal ctx, Handler<AsyncResult<HttpClientConnection>> handler) {
pool.getConnection(handler);
}
}