Skip to content

fix: support run verification on async context - #45

Merged
Mollemoll merged 5 commits into
Mollemoll:mainfrom
augustoccesar:augustoccesar/fix-run-on-async-context
Aug 5, 2025
Merged

fix: support run verification on async context#45
Mollemoll merged 5 commits into
Mollemoll:mainfrom
augustoccesar:augustoccesar/fix-run-on-async-context

Conversation

@augustoccesar

Copy link
Copy Markdown
Collaborator

Description

This PR changes so that the verification can be called from an asynchronous context.
To achieve this, have replaced reqwest blocking with ureq. Reqwest blocking does not work on asynchronous contexts.

the functionality in reqwest::blocking must not be executed within an async runtime, or it will panic when attempting to block.
-- https://docs.rs/reqwest/latest/reqwest/blocking/

If need to be ran on async context, the recommendation is to use tokio::task::spawn_blocking

If the immediate context is only synchronous, but a transitive caller is async, consider changing that caller to use tokio::task::spawn_blocking around the calls that need to block.
-- https://docs.rs/reqwest/latest/reqwest/blocking/

But this would make so that the library depends on Tokio. Since it seems like the original goal was to stay on synchronous, ureq fits that better

It uses blocking I/O instead of async I/O, because that keeps the API simple and keeps dependencies to a minimum.
-- https://github.com/algesten/ureq

I guess that if in the future we would like to support both sync and async, an implementation of a feature-gated runtime to choose which one to do might be the way to go. But that might be unnecessary atm.

Closes #42

@augustoccesar
augustoccesar marked this pull request as draft August 5, 2025 06:14
@augustoccesar
augustoccesar marked this pull request as ready for review August 5, 2025 06:25
@Mollemoll
Mollemoll merged commit 2dc1340 into Mollemoll:main Aug 5, 2025
4 checks passed
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.

Support async runtime

2 participants