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

http-cache with ureq #91

Open
mrchantey opened this issue Nov 18, 2024 · 8 comments
Open

http-cache with ureq #91

mrchantey opened this issue Nov 18, 2024 · 8 comments

Comments

@mrchantey
Copy link

I'm working on a feature that requires the use of ureq as well as http caching, any tips or prior art for using http-cache with ureq?

@06chaynes
Copy link
Owner

When I had first looked into it some years ago ureq didn't appear to have middleware support, but I see now that has since changed. Given that it may be possible but I would need to play around with it to know for sure.

If I get some free time soon I'll look into what it would take to create a ureq client library for http-cache.

@06chaynes
Copy link
Owner

06chaynes commented Nov 19, 2024

@mrchantey i noticed in the linked issue that one problem with using reqwest was the requirement of tokio.

Because http-cache is an async library we will need to deal with this somehow to use with ureq. Since this library would really start off for your use case do you have any input on how this might best be handled? It's my understanding we would need to import some async runtime to do this, but maybe there's another way I'm just not aware of.

Edit: to clarify this would be a requirement for the ureq http cache client library, not your code itself. But I want to check for any opinions on the matter before I attempt to throw something together.

@mrchantey
Copy link
Author

mrchantey commented Nov 20, 2024

Good question the requests are made in a non-tokio async block, its my understanding that bevy has some custom async implementation.

The first implementation used surf and http-cache-surf wich did work, code here, but when we tried replacing it with reqwest it seemed to require tokio async. The decision was made to use ureq because its lightweight, heres a bit more context in the discord.

I think @aevyrie would be a good person to ask about deeper bevy async stuff if required.

@06chaynes
Copy link
Owner

I think I might be able to use futures::executor::block_on for this. I will try to throw something together and see what happens.

@06chaynes
Copy link
Owner

06chaynes commented Nov 23, 2024

Made an effort to start on this but running into some lifetime problems that I think are Send/Sync related on the ureq Middleware trait. Will look into this again as I have time but if any progress is made your way I'd also be happy to accept a PR.

@mrchantey
Copy link
Author

Sounds good thanks for giving it a look.

@06chaynes
Copy link
Owner

06chaynes commented Dec 1, 2024

I think what this may require me to do is to revisit the refactor I had attempted a few years ago, which was originally started to better support tower and therefore hyper. I hit a blocker with the tower service and the refactor didn't go anywhere. I ran into problems when trying to implement a ureq client library with things as they currently are, and I think this refactor may get around those issues.

I had pushed the code I had to the refactor branch so it wouldn't be lost but it would need some work before I could merge anything. To save time I think I will try to make the client against the refactor branch code and just see how far I get. If it does work out then I will pursue getting the refactor finished and updated with the changes that have been added in since the attempt was made.

@mrchantey
Copy link
Author

For the Bevy use-case Ive added a very simple cache that never invalidates, its better than nothing but id still love to work out how to integrate http-cache.

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

No branches or pull requests

2 participants