-
Notifications
You must be signed in to change notification settings - Fork 566
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
Nima WebClient configuration for timeouts and keepAlive #6971
Nima WebClient configuration for timeouts and keepAlive #6971
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is what can be done with the reactive WebClient in 3.x and 2.x :
WebClient client = WebClient.builder()
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(10, TimeUnit.SECONDS)
.build();
WebClientResponse response = client.get()
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(10, TimeUnit.SECONDS)
.submit()
.await();
Here is some Nima based code:
Http1Client client =
Http1Client.builder()
.channelOptions(SocketOptions
.builder()
.connectTimeout(Duration.ofSeconds(30))
.readTimeout(Duration.ofSeconds(10))
.build())
//.connectTimeout(Duration.ofSeconds(30)) <-- shortcut
//.readTimeout(Duration.ofSeconds(10)) <-- shortcut
.build();
Http1ClientResponse response = client.get()
//.connectTimeout(Duration.ofSeconds(30)) <-- if possible
//.readTimeout(Duration.ofSeconds(10)) <-- if possible
.request();
The commented out code above is what needs to be implemented.
If I understand it correctly, these timeouts related to the timeouts from |
Here are some rough steps
public B readTimeout(Duration readTimeout) {
this.channelOptionsBuilder.readTimeout(readTimeout);
return (B) this;
}
public B connectTimeout(Duration connectTimeout) {
this.channelOptionsBuilder.connectTimeout(connectTimeout);
return (B) this;
} |
nima/webclient/webclient/src/main/java/io/helidon/nima/webclient/WebClient.java
Outdated
Show resolved
Hide resolved
nima/webclient/webclient/src/main/java/io/helidon/nima/webclient/WebClient.java
Outdated
Show resolved
Hide resolved
nima/webclient/webclient/src/main/java/io/helidon/nima/webclient/WebClient.java
Outdated
Show resolved
Hide resolved
nima/webclient/webclient/src/main/java/io/helidon/nima/webclient/WebClient.java
Outdated
Show resolved
Hide resolved
nima/webclient/webclient/src/main/java/io/helidon/nima/webclient/WebClient.java
Outdated
Show resolved
Hide resolved
nima/webclient/webclient/src/main/java/io/helidon/nima/webclient/ClientConfig.java
Outdated
Show resolved
Hide resolved
938a686
to
5103d7f
Compare
nima/webclient/webclient/src/main/java/io/helidon/nima/webclient/WebClient.java
Outdated
Show resolved
Hide resolved
Signed-off-by: aserkes <andrii.serkes@oracle.com> add shortcuts for timeouts Signed-off-by: aserkes <andrii.serkes@oracle.com> clean code Signed-off-by: aserkes <andrii.serkes@oracle.com> WebClient config for keepAlive Signed-off-by: aserkes <andrii.serkes@oracle.com> fix checkstyle Signed-off-by: aserkes <andrii.serkes@oracle.com>
…ild method. This allows WebClient.Builder to run pre-build code to set the channel options from the default builder. Slight re-org of WebClient.Builder: - move all package private methods at the bottom - add javadoc to protected methods Update javadoc related to the default socket options builder.
aa264c6
to
0ec2876
Compare
) * Nima WebClient Shortcuts for timeouts * WebClient config for keepAlive * Implement build() in WebClient.Builder and introduce an abstract doBuild method. This allows WebClient.Builder to run pre-build code to set the channel options from the default builder. Slight re-org of WebClient.Builder: - move all package private methods at the bottom - add javadoc to protected methods Update javadoc related to the default socket options builder. --------- Signed-off-by: aserkes <andrii.serkes@oracle.com> Co-authored-by: Romain Grecourt <romain.grecourt@oracle.com>
) * Nima WebClient Shortcuts for timeouts * WebClient config for keepAlive * Implement build() in WebClient.Builder and introduce an abstract doBuild method. This allows WebClient.Builder to run pre-build code to set the channel options from the default builder. Slight re-org of WebClient.Builder: - move all package private methods at the bottom - add javadoc to protected methods Update javadoc related to the default socket options builder. --------- Signed-off-by: aserkes <andrii.serkes@oracle.com> Co-authored-by: Romain Grecourt <romain.grecourt@oracle.com>
) * Nima WebClient Shortcuts for timeouts * WebClient config for keepAlive * Implement build() in WebClient.Builder and introduce an abstract doBuild method. This allows WebClient.Builder to run pre-build code to set the channel options from the default builder. Slight re-org of WebClient.Builder: - move all package private methods at the bottom - add javadoc to protected methods Update javadoc related to the default socket options builder. --------- Signed-off-by: aserkes <andrii.serkes@oracle.com> Co-authored-by: Romain Grecourt <romain.grecourt@oracle.com>
Fixes #6961
Fixes #6979