Skip to content

Commit

Permalink
Update endpoint API with @VertxGen
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed May 16, 2024
1 parent e09909b commit 56e2b1e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public HttpClientAgent build() {
CloseFuture cf = resolveCloseFuture();
HttpClientAgent client;
Closeable closeable;
EndpointResolver<?> resolver = endpointResolver(co);
EndpointResolver resolver = endpointResolver(co);
if (co.isShared()) {
CloseFuture closeFuture = new CloseFuture();
client = vertx.createSharedResource("__vertx.shared.httpClients", co.getName(), closeFuture, cf_ -> {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/vertx/core/http/impl/HttpClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ public class HttpClientImpl extends HttpClientBase implements HttpClientInternal

private final PoolOptions poolOptions;
private final io.vertx.core.net.impl.endpoint.EndpointManager<EndpointKey, SharedClientHttpStreamEndpoint> httpCM;
private final EndpointResolverInternal<Address> endpointResolver;
private final EndpointResolverInternal endpointResolver;
private volatile Function<HttpClientResponse, Future<RequestOptions>> redirectHandler = DEFAULT_HANDLER;
private long timerID;
private volatile Handler<HttpConnection> connectionHandler;
private final Function<ContextInternal, ContextInternal> contextProvider;

public HttpClientImpl(VertxInternal vertx,
EndpointResolver<?> endpointResolver,
EndpointResolver endpointResolver,
HttpClientOptions options,
PoolOptions poolOptions) {
super(vertx, options);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/io/vertx/core/net/endpoint/Endpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
*/
package io.vertx.core.net.endpoint;

import io.vertx.codegen.annotations.VertxGen;

import java.util.List;

@VertxGen
public interface Endpoint {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
*/
package io.vertx.core.net.endpoint;

import io.vertx.codegen.annotations.VertxGen;

/**
* Request interaction with an endpoint, mostly callbacks to gather statistics.
*
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
*/
@VertxGen
public interface EndpointInteraction {

/**
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/io/vertx/core/net/endpoint/EndpointNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
*/
package io.vertx.core.net.endpoint;

import io.vertx.codegen.annotations.GenIgnore;
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.net.SocketAddress;

/**
* A physical node of an endpoint.
*
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
*/
@VertxGen
public interface EndpointNode {

/**
Expand All @@ -37,7 +40,10 @@ public interface EndpointNode {
EndpointInteraction newInteraction();

// Should be private somehow
@GenIgnore
InteractionMetrics<?> metrics();

@GenIgnore
Object unwrap();

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
package io.vertx.core.net.endpoint;

import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.Future;
import io.vertx.core.net.Address;

Expand All @@ -18,13 +19,14 @@
*
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
*/
public interface EndpointResolver<A extends Address> {
@VertxGen
public interface EndpointResolver {

/**
* Resolver an endpoint for the specified {@code address}
* @param address the address to lookup
* @return the endpoint lookup result
*/
Future<Endpoint> resolveEndpoint(A address);
Future<Endpoint> resolveEndpoint(Address address);

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
*/
public class EndpointResolverImpl<S, A extends Address, E> implements EndpointResolverInternal<A> {
public class EndpointResolverImpl<S, A extends Address, E> implements EndpointResolverInternal {

private final VertxInternal vertx;
private final LoadBalancer loadBalancer;
Expand Down Expand Up @@ -67,11 +67,11 @@ public void checkExpired() {
}

@Override
public Future<io.vertx.core.net.endpoint.Endpoint> resolveEndpoint(A address) {
public Future<io.vertx.core.net.endpoint.Endpoint> resolveEndpoint(Address address) {
return lookupEndpoint2(vertx.getOrCreateContext(), address);
}

public Future<io.vertx.core.net.endpoint.Endpoint> lookupEndpoint(ContextInternal ctx, A address) {
public Future<io.vertx.core.net.endpoint.Endpoint> lookupEndpoint(ContextInternal ctx, Address address) {
return lookupEndpoint2(ctx, address);
}

Expand Down Expand Up @@ -116,7 +116,7 @@ public EndpointNode selectNode(String key) {
}
}

private Future<io.vertx.core.net.endpoint.Endpoint> lookupEndpoint2(ContextInternal ctx, A address) {
private Future<io.vertx.core.net.endpoint.Endpoint> lookupEndpoint2(ContextInternal ctx, Address address) {
A casted = endpointResolver.tryCast(address);
if (casted == null) {
return ctx.failedFuture("Cannot resolve address " + address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import io.vertx.core.net.endpoint.Endpoint;
import io.vertx.core.net.endpoint.EndpointResolver;

public interface EndpointResolverInternal<A extends Address> extends EndpointResolver<A> {
public interface EndpointResolverInternal extends EndpointResolver {

Future<Endpoint> lookupEndpoint(ContextInternal ctx, A address);
Future<Endpoint> lookupEndpoint(ContextInternal ctx, Address address);

/**
* Check expired endpoints, this method is called by the client periodically to give the opportunity to trigger eviction
Expand Down

0 comments on commit 56e2b1e

Please sign in to comment.