Fully synchronous (no async or multithreads) REST API client


I am looking for low-level REST/HTTP library which would not contain any aync/multithreading, and is fully syncronous non-blocking

The typical workflow that I am looking for in case of other network communications (when REST/HTTP is not present)

  1. Manually open TCP socket
  2. Manully send REST request from main thread and immidately give access to main thread back
  3. Do other computationally intensive stuff in the same thread
  4. When I am not doing anything in (3) and application have free time - go to Socket (1) and read REST responce
  5. Act on the rest responce and other variables and send another REST request

Most of the libraries I've seen are heavily burdened by lots of unnesessary code and more importantly it slows down the main thread (we are talking about 1-10 microsecond scale delays which are relevant for our application)

Are there any fully synchronous REST/HTTP libraries with no async/multithreading. We are completely fine working with the raw TCP socket, just don't want to deal with HTTP/REST nuances and want the intermidiate library just barely help to handle those details, not force us to be async/multithreaded

Thank you!

If you want to process HTTP while doing IO in an unusual fashion, you might start with the http library. It's what HTTP clients like reqwest use to handle the protocol work.

That said, I think you might misunderstand async. Async doesn't necessarily mean that there are threads; most async executors have single-threaded versions if they aren't inherently single-threaded. In fact, it is not hard to write your own custom async executor that performs whatever scheduling policy suits your needs. “Do task X until it is idle and then do task Y if it has anything to do” is entirely possible. (In fact, it could even be expressed as an impl Future for … that you then run inside an existing executor such as the tokio executor that reqwest wants; all it has to do is “unfairly” poll the two child tasks when it is polled.)

You might still need to write your own code to be able to tweak it for the performance properties you're looking for — but I think you won't find very many high-level (like HTTP) non-blocking protocol libraries in Rust that aren't built with async, because async is how the Rust ecosystem approaches non-blocking IO in a reusable fashion.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.