-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement a builder for HttpClient, this will be useful for configuri…
…ng the address resolver for service discovery. The builder allows to retrofit the client redirect/connect handlers like done in SQL client.
- Loading branch information
Showing
27 changed files
with
630 additions
and
367 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 |
---|---|---|
|
@@ -11,35 +11,43 @@ | |
package io.vertx.core.http; | ||
|
||
import io.vertx.codegen.annotations.Fluent; | ||
import io.vertx.codegen.annotations.GenIgnore; | ||
import io.vertx.codegen.annotations.VertxGen; | ||
import io.vertx.core.Future; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.net.ClientSSLOptions; | ||
import io.vertx.core.net.SSLOptions; | ||
|
||
import java.util.function.Function; | ||
|
||
/** | ||
* A builder for {@link HttpClient}. | ||
* | ||
* @author <a href="mailto:[email protected]">Julien Viet</a> | ||
*/ | ||
@VertxGen | ||
public interface HttpClientPool extends HttpClient, io.vertx.core.metrics.Measured { | ||
public interface HttpClientBuilder { | ||
|
||
/** | ||
* Update the client SSL options. | ||
* | ||
* Update only happens if the SSL options is valid. | ||
* | ||
* @param options the new SSL options | ||
* @return a future signaling the update success | ||
* Configure the client options. | ||
* @param options the client options | ||
* @return a reference to this, so the API can be used fluently | ||
*/ | ||
Future<Void> updateSSLOptions(ClientSSLOptions options); | ||
@Fluent | ||
HttpClientBuilder with(HttpClientOptions options); | ||
|
||
/** | ||
* Configure the client with the given pool {@code options}. | ||
* @param options the pool options | ||
* @return a reference to this, so the API can be used fluently | ||
*/ | ||
@Fluent | ||
HttpClientBuilder with(PoolOptions options); | ||
|
||
/** | ||
* Set a connection handler for the client. This handler is called when a new connection is established. | ||
* | ||
* @return a reference to this, so the API can be used fluently | ||
*/ | ||
@Fluent | ||
HttpClientPool connectionHandler(Handler<HttpConnection> handler); | ||
HttpClientBuilder withConnectHandler(Handler<HttpConnection> handler); | ||
|
||
/** | ||
* Set a redirect handler for the http client. | ||
|
@@ -61,12 +69,12 @@ public interface HttpClientPool extends HttpClient, io.vertx.core.metrics.Measur | |
* @return a reference to this, so the API can be used fluently | ||
*/ | ||
@Fluent | ||
HttpClientPool redirectHandler(Function<HttpClientResponse, Future<RequestOptions>> handler); | ||
HttpClientBuilder withRedirectHandler(Function<HttpClientResponse, Future<RequestOptions>> handler); | ||
|
||
/** | ||
* @return the current redirect handler. | ||
* Build and return the client. | ||
* @return the client as configured by this builder | ||
*/ | ||
@GenIgnore | ||
Function<HttpClientResponse, Future<RequestOptions>> redirectHandler(); | ||
HttpClient build(); | ||
|
||
} |
This file contains 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.