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

Async File Systems #53

Open
Nikey646 opened this issue Oct 31, 2020 · 5 comments
Open

Async File Systems #53

Nikey646 opened this issue Oct 31, 2020 · 5 comments

Comments

@Nikey646
Copy link

Is there any plans to allow the implementation of Async File Systems, EG: Azure Blob?

@xoofx
Copy link
Owner

xoofx commented Nov 7, 2020

No plan, as I don't have a personal use for this feature.
but It is definitely possible to bring support for async. It would require to duplicate the interface and implement all the Async methods. It's a bit of work, but should not be too difficult. PR welcome.

@Nikey646
Copy link
Author

Nikey646 commented Nov 9, 2020

When looking at the IFileSystem interface, would you want every method to have an Async counter part?

When adding to the existing implementations, would you rather just call Task.FromResult(SyncImpl());?

When the implementation only provides a Async implementations (All of the files are in Azure Blob), should the Sync methods just call the Async methods with .GetAwaiter().GetResult() to make the execution occur in the current thread?

@xoofx
Copy link
Owner

xoofx commented Nov 27, 2020

Ooops, sorry to get back to you only now, I thought I responded immediately.

When looking at the IFileSystem interface, would you want every method to have an Async counter part?

I would believe.

When adding to the existing implementations, would you rather just call Task.FromResult(SyncImpl());?

Yes, except that all methods should return a ValueTask instead.

When the implementation only provides a Async implementations (All of the files are in Azure Blob), should the Sync methods just call the Async methods with .GetAwaiter().GetResult() to make the execution occur in the current thread?

Likely yes.

@GerardSmit
Copy link
Contributor

FYI: Someone made source generator that generates sync methods from async methods; https://github.com/zompinc/sync-method-generator.
It's the other away around for Zio, so it would still require a lot of refactoring to async methods (what Sébastien did in #62) but it would remove the need for duplicated code.

@xoofx
Copy link
Owner

xoofx commented Oct 28, 2022

Yep, I tried to reuse the technique I used for Generate automatically async/await code from sync code with Roslyn that I'm using for another project, but as the generator was specific to the library, I took some shortcuts and so it's not reusable as it is. Would take quite some time to make it working, possible, but time costly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants