Skip to content

Conversation

@lippserd
Copy link
Member

No description provided.

@lippserd lippserd added this to the v1.0.0-rc2 milestone Jun 18, 2021
@lippserd lippserd marked this pull request as ready for review June 21, 2021 16:03
@lippserd lippserd requested a review from julianbrost June 21, 2021 16:03
Our driver now supports DriverContext and uses contexts.
This basically supports that the connect function returns
immediately when a context is cancelled.
Copy link
Member

@julianbrost julianbrost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the Go sql package guarantee to always use DriverContext if available? Or would it make sense to also explicitly implement the Open() function from the Driver interface (simply calling Connect(context.Background())) to ensure that Open() also retries?

@lippserd
Copy link
Member Author

Does the Go sql package guarantee to always use DriverContext if available? Or would it make sense to also explicitly implement the Open() function from the Driver interface (simply calling Connect(context.Background())) to ensure that Open() also retries?

Yep, DriverContext will always be used if available:

https://github.com/golang/go/blob/2ebe77a2fda1ee9ff6fd9a3e08933ad1ebaea039/src/database/sql/driver/driver.go#L10
https://github.com/golang/go/blob/2ebe77a2fda1ee9ff6fd9a3e08933ad1ebaea039/src/database/sql/driver/driver.go#L97
https://github.com/golang/go/blob/10d625d5b41f17c118da18a592c683e60fcdcb3b/src/database/sql/sql.go#L824

@lippserd lippserd merged commit f8315de into master Jun 23, 2021
@lippserd lippserd deleted the driver-context branch June 23, 2021 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants