Skip to content
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

implement IDisposable in IDocumentStorageService #8083

Merged
merged 3 commits into from
Nov 8, 2021

Conversation

znewton
Copy link
Contributor

@znewton znewton commented Nov 1, 2021

First PR to address #5980. After this is checked in and released, I have changes staged locally to consume this type change across client packages.

@znewton znewton requested a review from a team as a code owner November 1, 2021 20:42
@github-actions github-actions bot added area: definitions public api change Changes to a public API labels Nov 1, 2021
@github-actions github-actions bot requested review from vladsud and curtisman and removed request for a team November 1, 2021 20:43
@@ -91,7 +91,7 @@ export interface IDocumentStorageServicePolicies {
/**
* Interface to provide access to snapshots saved for a shared object
*/
export interface IDocumentStorageService {
export interface IDocumentStorageService extends IDisposable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export interface IDocumentStorageService extends IDisposable {
export interface IDocumentStorageService extends Partial<IDisposable> {

we should avoid breaking changes. can we start with making in optional, so implementations don't break

Copy link
Contributor

@anthony-murphy anthony-murphy Nov 2, 2021

Choose a reason for hiding this comment

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

also is this totally necessary on the interface? is it possible to only use on the implementation? who will be expected to call this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently it is only used on the implementation, so yes, it's possible. However, doing so can restrict the "wrapping" order of DocumentStorageServices. The primary example, and reason that the issue for this was opened, is RetriableDocumentStorageService, which implements IDisposable. There was a bug in PrefetchDocumentStorageService, which was wrapped by RetriableDocumentStorageService. @vladsud recommended simply changing the wrapping order to address it. Without this type change, it's messy for storage services that wrap others to check if the internal storage service is disposable and should be disposed.

Let me know if I misunderstood the question, but it seems there has been enough other people say "IDocumentStorageService should just always extend IDisposable" (@vladsud, you, and @ChumpChief) that this seems like an OK change, even if not totally necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say - yes they should. But that might still require staged rollout / injecting some delays. Basically there is no easy way to tie version of protocol / definitions to versions and expectations of packages, so declaring it required allows for loader / runtime layer to take advantage of it while using old driver version. So likely we want to add implementations, ship them, and then after some time make interface requirement non-optional. It sucks, but such is life of supporting back compat

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for all the input, Anthony and Vlad. I've made the interface change optional, which makes it back/forward compatible.

Copy link
Contributor

Choose a reason for hiding this comment

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

My main question would be the same as Tony's, "who will be expected to call this?"

Is it OK for anyone with access to an IDocumentStorageService to call dispose()? I would guess probably not? So if there's some way to restrict access to whoever is the manager of its lifetime would be good.

Copy link
Contributor

Choose a reason for hiding this comment

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

i think leaving it partial it probably the right answer. this allows anyone that want to manage the lifetime to expose a wrapper without dispose to consumers, but makes it easy for implementors to know where to clean up if they need to

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm maybe not familiar enough with the runtime and loader space to best answer that question 😕 . I would think it's not too different from today though where the top level DocumentStorageService is a RetriableDocumentStorageService which extends IDisposable already. My intent here would be to make it easier for the top-level DocumentStorageService to be something other than RetriableDocumentStorageService, but still make it possible to dispose of that service and its internal services.

Make IDisposable optional for now

Co-authored-by: Tony Murphy <anthony.murphy@microsoft.com>
@znewton znewton force-pushed the disposable-docstorageservice branch from fc80e99 to bc061e8 Compare November 2, 2021 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants