-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
API Review: should IResettableService.ResetStateAsync() return ValueTask #16675
Comments
Make it |
Note that I checked, and |
@roji is cancelling the reset meaningful? |
I admit I only added this after the API consistency tests raised an error, and I hesitated about this for a while. The general practice seems to be to always allow async operations to be cancellable by default, except for some very specific cases, such as the DisposeAsync pit of failure. That specific pit of failure doesn't seem to exist here, so there's at least no strong reason not to make it cancellable. Here's a (very) theoretical case where this could be useful. We currently reset DbContext's services sequentially, one by one. This in theory could be done in parallel with Task.WhenAll (although if services are expected to use the same connection resource, that would be a big bug). In this scenario, if one of the services throws an exception (i.e. failed to reset), we should issue cancellations on the others before discarding the poolable context. Basically it's about IResettableService being a public abstraction, so we're not sure exactly where it will end up. If you have strong feelings against this (especially if you see some pit of failure) we can revert. |
Currently
IResettableService.ResetStateAsync()
returns ValueTask since the one place we need an async path is inRelationalConnection
where we use it to async dispose theDbConnection
and theDbTransaction
:So there are no async paths that this uses that call any
Task
returning async methods.The text was updated successfully, but these errors were encountered: