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

Built-in support for event loops #62

Open
xsawyerx opened this issue Apr 12, 2022 · 0 comments
Open

Built-in support for event loops #62

xsawyerx opened this issue Apr 12, 2022 · 0 comments

Comments

@xsawyerx
Copy link
Collaborator

Since this module primarily does I/O, it would be good to support an event loop.

I've made the resumable upload method upload_file_content_iterator() for this purpose, but it doesn't help that everything else is done with synchronous requests, including the preliminary request that is required for this method (create_resumable_upload() or create_resumable_upload_for()).

I can think of several ways to try and support event loops:

  1. We can switch to an event loop. My money is on IO::Async since it works with other loops and its author is active and friendly.
  2. Same as No. 1 but make it optional, like a setting or a detection.
  3. We can come up with a simple way to subclass the http_loop() method so people can create their own variations.
  4. We can have a parameter for the http_loop() that makes it easy to hook up another event loop (this is tricky)
  5. We can make the request a hook instead, so people can provide a callback for handling requests (this is also tricky)
  6. We can add an optional callback for every operation and set the default to what we would do with it
  7. Switch everything to Promises or Futures and allow the user to trigger the call

I haven't yet looked enough into it to decide which approach is best but I'm inclined to go with No. 7 since it provides the cleanest interface for handling sync and async by making everything a Future that is either satisfied immediately (sync) or later (async) by whatever event loop you are using. Future.pm has clean interfaces for many event loops and you can always add your own easily.

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

No branches or pull requests

1 participant