Skip to content

feat: Add SpawnService and SpawnedReqwestConnector for running requests on a different runtime #332

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

Merged
merged 13 commits into from
May 6, 2025

Conversation

ion-elgreco
Copy link
Contributor

@ion-elgreco ion-elgreco commented Apr 13, 2025

Which issue does this PR close?

Adds support for spawning reqwuests tasks to another Runtime. Credits to @tustvold, I simply added an additional connector in there to make it easier for others to integrate this in their code base.

Example:

  let prefix = Path::parse(path)?;
  let mut builder = MicrosoftAzureBuilder::new().with_url(url.to_string());
  for (key, value) in config.iter() {
      builder = builder.with_config(*key, value.clone());
  }
  let inner = builder
      .with_retry(self.parse_retry_config(options)?)
      .with_http_connector(SpawnedReqwestConnector::new(io_handle))
      .build()?;

Rationale for this change

Allows a separation of cpu bound tasks and io bound tasks

What changes are included in this PR?

  • Adds a SpawnService
  • Adds a SpawnedReqwestConnector

Are there any user-facing changes?

Only an additional http_connector.

cc @alamb 😃

@ion-elgreco ion-elgreco marked this pull request as ready for review April 13, 2025 10:00
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @ion-elgreco (and @tustvold ) -- this is great.

I think it would help a lot of we could add some more documentation / examples

Basically, imagine someone coming to https://docs.rs/object_store/latest/object_store/

  1. How would they find out about this feature / decide when to use it
  2. How would they be able to use it?

Perhaps we could

  1. Add a brief section after TLS Certificiates with a pointer to the src/client/http module
  2. Add some documentation examples in http with pointers to SpawnService

I can try and help with this documentation later this week

Example:

Is there any chance you can add this example somewhere?

@alamb alamb requested a review from tustvold April 13, 2025 12:34
@alamb
Copy link
Contributor

alamb commented Apr 13, 2025

FYI @kylebarron

@ion-elgreco
Copy link
Contributor Author

@alamb sure! I'll add more docs tomorrow

@ion-elgreco
Copy link
Contributor Author

@alamb I've added some docs

@alamb
Copy link
Contributor

alamb commented Apr 15, 2025

Note due to #335 the CI was not running. I plan to merge up from main shortly

@alamb alamb changed the title feat: spawn-service feat: Add SpawnService and SpawnedReqwestConnector for running requests on a different runtime Apr 15, 2025
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @ion-elgreco 🙏

As I mentioned I spent a while longer today updating the docs and adding some more tests. I think this PR is now ready to rock. Thank you so much

This completes a feature we have been talking about / discussing for over a year. 💯 🦾 !

FYI @crepererum and @tustvold


/// Integration test that ensures I/O is done on an alternate threadpool
/// when using the `SpawnedReqwestConnector`.
#[test]
Copy link
Contributor

Choose a reason for hiding this comment

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

I also wrote this end to end integration test to ensure that everything worked correctly when hooked up to an ObjectStore implementation (and it does!)


// Runtime with I/O enabled
let io_runtime = tokio::runtime::Builder::new_current_thread()
.enable_all() // <-- turns on IO
Copy link
Contributor

Choose a reason for hiding this comment

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

if you comment out this line the test fails

@alamb
Copy link
Contributor

alamb commented Apr 17, 2025

I am out starting tomorrow for a week, so if another committer doesn't merge this before I will do so when I get back

Thanks again @ion-elgreco

@tustvold
Copy link
Contributor

This appears to have accumulated some merge conflicts

@alamb
Copy link
Contributor

alamb commented Apr 28, 2025

This appears to have accumulated some merge conflicts

I'll try and fix it

@ion-elgreco
Copy link
Contributor Author

@alamb resolved the merge conflict with the new Zed merge conflict functionality :P

@alamb
Copy link
Contributor

alamb commented May 6, 2025

I am looking at the WASM issue

@alamb
Copy link
Contributor

alamb commented May 6, 2025

I think we are ready , let's merge this in!

@alamb alamb merged commit e0625b3 into apache:main May 6, 2025
@alamb
Copy link
Contributor

alamb commented May 6, 2025

Thanks again @ion-elgreco for helping push this over the line

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

Successfully merging this pull request may close these issues.

[object_store] Run requests on a different tokio runtime
3 participants