-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add timeouts, cleanup #1336
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
Merged
Merged
Add timeouts, cleanup #1336
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ce1fe66
Add timeouts, cleanup
KostyaSha ae312bc
Enlarge timeout
KostyaSha b04832d
restore value ffor tests
KostyaSha 4dadc6f
Mac ttypos
KostyaSha 5bfa433
Configurable options with default
KostyaSha 10d8350
allign
KostyaSha f43118a
Comment
KostyaSha 113a6f5
Unformat
KostyaSha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| package com.github.dockerjava.netty; | ||
|
|
||
| import static com.google.common.base.Preconditions.checkNotNull; | ||
| import static java.util.Objects.nonNull; | ||
|
|
||
| import java.io.IOException; | ||
| import java.net.InetAddress; | ||
|
|
@@ -58,7 +59,7 @@ | |
| * @see https://docs.docker.com/engine/reference/api/docker_remote_api_v1.21/#attach-to-a-container | ||
| * @see https://docs.docker.com/engine/reference/api/docker_remote_api_v1.21/#exec-start | ||
| */ | ||
| public class NettyDockerCmdExecFactory extends AbstractDockerCmdExecFactory implements DockerCmdExecFactory { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. redundant implements |
||
| public class NettyDockerCmdExecFactory extends AbstractDockerCmdExecFactory { | ||
|
|
||
| private static String threadPrefix = "dockerjava-netty"; | ||
|
|
||
|
|
@@ -88,10 +89,6 @@ public DuplexChannel getChannel() { | |
| } | ||
| }; | ||
|
|
||
| private Integer connectTimeout = null; | ||
|
|
||
| private Integer readTimeout = null; | ||
|
|
||
| @Override | ||
| public void init(DockerClientConfig dockerClientConfig) { | ||
| super.init(dockerClientConfig); | ||
|
|
@@ -292,29 +289,13 @@ public void close() throws IOException { | |
| eventLoopGroup.shutdownGracefully(); | ||
| } | ||
|
|
||
| /** | ||
| * Configure connection timeout in milliseconds | ||
| */ | ||
| public NettyDockerCmdExecFactory withConnectTimeout(Integer connectTimeout) { | ||
| this.connectTimeout = connectTimeout; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Configure read timeout in milliseconds | ||
| */ | ||
| public NettyDockerCmdExecFactory withReadTimeout(Integer readTimeout) { | ||
| this.readTimeout = readTimeout; | ||
| return this; | ||
| } | ||
|
|
||
| private <T extends Channel> T configure(T channel) { | ||
| ChannelConfig channelConfig = channel.config(); | ||
|
|
||
| if (connectTimeout != null) { | ||
| if (nonNull(connectTimeout)) { | ||
| channelConfig.setConnectTimeoutMillis(connectTimeout); | ||
| } | ||
| if (readTimeout != null) { | ||
| if (nonNull(readTimeout)) { | ||
| channel.pipeline().addLast("readTimeoutHandler", new ReadTimeoutHandler()); | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
readTimeoutis wrong since there can be long living connections. The correct approach would be to use timeouts/deadlines when executing the commandsUh oh!
There was an error while loading. Please reload this page.
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.
For library that doesn't matter, you can set any timeouts on your app side.
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.
you should not be setting the default read timeout here. Some operations last minutes or even hours. The callee should set the timeouts at the use site