-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Support prioritization of DockerClientProviderStrategies #362
Conversation
return true; | ||
} | ||
|
||
protected int getPriority() { |
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.
Maybe worth mentioning in a comment how the priority is used (i.e. highest to lowest) for avoidance of doubt.
throw new IllegalStateException("Could not find a valid Docker environment. Please see logs and check configuration"); | ||
return strategies.stream() | ||
.filter(DockerClientProviderStrategy::isApplicable) | ||
.sorted(Comparator.comparing(DockerClientProviderStrategy::getPriority).reversed()) |
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.
My only slight concern with determining the order at run time is that it means there's no one place you can look in the code to see the sequence. Now people will have to look at the implementations of all the strategies to figure out what order they'll run in.
Having said that, this does allow us to do dynamic prioritisation. So, e.g. as I mentioned on Slack, caching last known good config somewhere. Is that the kind of thing you had in mind too?
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.
Ignore that - the PR title gives it away 🤦♂️
👍 !
… selected DockerClientProviderStrategy globally.
# Conflicts: # CHANGELOG.md # core/src/main/java/org/testcontainers/utility/TestcontainersConfiguration.java
# Conflicts: # CHANGELOG.md
To improve the start-up time, we can adjust the priorities of strategies based on the environment.
Please review "isApplicable" very carefully to avoid some breaking changes :)