feat(java): Support connection timeout#3026
Conversation
…(and sync) clients
…issing coverage for other code paths
jrhenderson1988
left a comment
There was a problem hiding this comment.
@mmodzelewski I've added a few extra tests in this PR where I noticed there was some missing coverage.
On the flip side, I didn't quite know how we could actually test the connection timeout using the integration style tests that we run. Not sure if we have a current way of forcing a slow connection or introducing some latency to make the timeout kick in. I know that there are tools that could be used like Toxiproxy for example, but not sure if it would be desirable to add it (and I'm not that familiar with it). If you have any ideas, do let me know
foreign/java/java-sdk/src/main/java/org/apache/iggy/client/async/tcp/AsyncIggyTcpClient.java
Show resolved
Hide resolved
.../java/java-sdk/src/main/java/org/apache/iggy/client/async/tcp/AsyncIggyTcpClientBuilder.java
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3026 +/- ##
=========================================
Coverage 71.74% 71.75%
- Complexity 930 943 +13
=========================================
Files 1121 1121
Lines 93777 93800 +23
Branches 71125 71125
=========================================
+ Hits 67284 67307 +23
- Misses 23856 23858 +2
+ Partials 2637 2635 -2
🚀 New features to boost your workflow:
|
|
Currently getting build failures on Cyclomatic and NPath complexity in the build method, since I added an additional validation for the |
|
Overall LGTM, just some minor issues including several comments copy-pasting in tests |
|
@ex172000 did you mean to add any comments to the code? @jrhenderson1988 let's try to refactor the code to keep the existing gate levels. |
|
Thank you both for the reviews. @ex172000 I think I've fixed the comment copy/paste issue. I could only see one occurrence. @mmodzelewski I've refactored the logic to keep the complexity of the method down below the gates. I had a look to see if there was something we could use from Netty to get it to simulate a connection failure but it doesn't look like there was anything. I did manage to surface a faillure by making it connect to 192.0.2.1 with a 100ms timeout and it threw an exception: Not sure if that's something we'd like to wrap and throw an Iggy based exception instead. What do you think? Let me know if you would like any further changes. If not, this is ready to review again. |
|
.../java/java-sdk/src/main/java/org/apache/iggy/client/async/tcp/AsyncIggyTcpClientBuilder.java
Outdated
Show resolved
Hide resolved
...a/java-sdk/src/test/java/org/apache/iggy/client/async/tcp/AsyncIggyTcpClientBuilderTest.java
Outdated
Show resolved
Hide resolved
…ing to Netty's configuration for connection timeout
We've got |
|
@mmodzelewski I've just pushed an update where we check for Netty's |
mmodzelewski
left a comment
There was a problem hiding this comment.
@jrhenderson1988 Thanks, I think that looks good and we can merge. Additional tests can be introduced later.
Which issue does this PR close?
Closes #3010
Rationale
The connection timeout is a value supported by the builders of both the async and blocking TCP builders, but the clients that they build do not properly apply the connection timeout.
What changed?
Passes through the connection timeout into the
AsyncIggyTcpClientand the subsequentAsyncTcpConnectionwhere it is used in the bootstrap given to the connection pool. TheChannelOption.CONNECT_TIMEOUT_MILLISvalue is set with the value of the connection timeout in milliseconds, falling back to the 3000ms value that was used previously if it's not set.Local Execution
AI Usage