-
Notifications
You must be signed in to change notification settings - Fork 515
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
R2DBC: Await closing the driver #4139
Conversation
0d51e47
to
ee503b6
Compare
ee503b6
to
3c548f6
Compare
/** | ||
* This callback is called after [close]. It either contains an error or null, representing a successful close. | ||
*/ | ||
val closed: (Throwable?) -> Unit, |
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.
val closed: (Throwable?) -> Unit, | |
val closed: (Throwable?) -> Unit = {}, |
I feel like in most cases we don't actually need any special handing for 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.
Hm, yes and no. If you don't provide this value, you don't have an option to wait for the close call, because driver.close()
will return immediately.
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.
Wouldn't it return immediately anyway? I would expect that this could still work as a fire-and-forget kind of thing, but that passing in a listener will let you await the completion if you really need it.
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.
Of course, this call isn't suspending or blocking, see the tests for a waiting implementation.
So yes, you still need to implement the listener (or we could provide an CoroutineScope
overload).
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.
Sounds good to me either way
* R2DBC: Await closing the driver * Fix compiler error due to rebasing * Add coroutines overload * Add doc * Refactor test code with use * Spotless... --------- Co-authored-by: hfhbd <hfhbd@users.noreply.github.com>
The current
close
api of the R2DBC driver does not await the result or failure of the close request. Because we can't use a suspend call, I added a normal plain old callback.