-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
#273: Expose connectTimeout as a configuration option #276
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.
@trasch sorry for tkaing so long to come back to you!
There is one direct code comment, and would you be open to add a test case for it?
public init(host: String, port: Int = 5432, connectTimeout: TimeAmount = .seconds(10)) { | ||
self.host = host | ||
self.port = port | ||
self.connectTimeout = connectTimeout |
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.
public init(host: String, port: Int = 5432, connectTimeout: TimeAmount = .seconds(10)) { | |
self.host = host | |
self.port = port | |
self.connectTimeout = connectTimeout | |
public init(host: String, port: Int = 5432) { | |
self.host = host | |
self.port = port | |
self.connectTimeout = .seconds(10) |
We sadly can not add another parameter to the initializer and not be source breaking. To work around this all properties are vars
by default. This way, if users want to override the value, they can just use the property after the init.
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.
No problem, but I have to admit that I don't understand why this is source breaking... 🙂 Shouldn't a new parameter with a default value at the end of the parameter list compile everywhere without problems?
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.
Yes, this API breaking change is very hard to see, but it occurs in this case:
Existing API:
struct Foo {
init(bar: String) {
}
static func test() {
let make = Foo.init(bar:)
let foo = make("hello")
// ...
}
}
Adding a defaulted value breaks this code however:
struct Foo {
init(bar: String, test: String = "foo") {
}
static func test() {
let make = Foo.init(bar:) // <--- ❌ compiler error
let foo = make("hello")
// ...
}
}
I would, and maybe you can give me a hint if there is already some code somewhere that opens a blocking port with which I could test this? |
@trasch after browsing around a bit, this seems to be quite hard to test... Sorry for making you look into it. Basically we would test nio functionality. If the CI passes, we should be good to go! |
Codecov Report
@@ Coverage Diff @@
## main #276 +/- ##
=======================================
Coverage 43.90% 43.91%
=======================================
Files 115 115
Lines 9675 9678 +3
=======================================
+ Hits 4248 4250 +2
- Misses 5427 5428 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Indeed, testing this would basically be replicating Thanks for reviewing this! |
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.
Awesome! Thanks for the contribution @trasch!
This exposes the
connectTimeout
property in the configuration.