Rotor HTTP Client

So I've been playing with the new HTTP client API in @tailhook 's rotor library and am looking for some advice on what I should be sharing across client requests.

Should I have a single Loop that instantiates a Context for each client request? Or a single Context that adds a machine for each request? Or should I require the user pass in a loop themselves so they maintain the granularity?

EDIT: After spending a bit more time playing with the example it looks like at least 1 Context per request makes sense, since that's where you could keep a callback function, or store a result for later inspection. Some confirmation would be good.

The question is pretty rotor-specific, and relates to a work-in-progress API, but I didn't think it was worth an issue on Github.

It's hard to answer without knowing what you are trying to achieve.

Rotor is designed in a way where you have single loop and a single Context. Context is where your globals are. And the exact type of Context is determined by end user application, not additional libraries. The library might require some trait on it however.

A callback should be put into state machine. Like this:

struct FuntionalClient(Box<FnMut(X) -> Y>);
impl ::rotor_http::client::Client for FunctinalClient {
  // ...
}

It's fine to create an issue for such questions.

1 Like

No problem, thanks. It is a bit ethereal because I'm not totally sure what my usecase is yet :slight_smile:

I'll keep playing with it qnd see what I come out with. Thanks again.