hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Make examples usable (TokioIo)

Open inferrna opened this issue 1 year ago • 12 comments

Currently, one does not simple create own project based on provided examples because almost all examples depends on internal structure TokioIo.

PS: already found TokioIo in hyper-util crate. At least, it should be added to https://github.com/hyperium/hyper/tree/master/examples#dependencies

inferrna avatar Nov 28 '23 19:11 inferrna

As mentioned in the hello example, we can't depend on hyper-util in hyper, because then it becomes a cyclical dependency.

Unless we changed the examples to not be a separate crate, instead of natural examples of hyper.

seanmonstar avatar Nov 28 '23 20:11 seanmonstar

Ok. Steps to reproduce.

  1. Forget all you know about hyper (If you can't do this, then try next steps on your grandma)
  2. Open examples
  3. Try to make own crate based on any of the examples using the README as a main information source.

I was succeeded after I googled https://hyper.rs/guides/1/client/basic/, and I would do this faster if there wasn't any README in examples folder (I used to trust README files)

inferrna avatar Nov 29 '23 05:11 inferrna

can be closed.

BuddhiAbeyratneAL avatar Dec 20 '23 18:12 BuddhiAbeyratneAL

@seanmonstar If hyper can't be used without the code, then maybe it shouldn't live in a separate hyper_util ?

erikschul avatar Jan 05 '24 13:01 erikschul

You can have non-Tokio reactors for Hyper, e.g. https://github.com/notgull/smol-hyper

notgull avatar Jan 05 '24 14:01 notgull

@seanmonstar If hyper can't be used without the code, then maybe it shouldn't live in a separate hyper_util ?

The whole idea is to allow users to easily choose a reactor for hyper (while also making it independent of tokio). tokio is the one mainly used at the moment, so some common and simple implementations for tokio with hyper are provided in the hyper-util crate instead.

dswij avatar Jan 09 '24 10:01 dswij

I do agree with the desire for the examples to be immediately usable. Perhaps the best solution is to convert the examples into a crate that's part of the workspace, instead of the crate "examples", and then we can properly depend on hyper-util in there. Is there a downside I'm not thinking off?

seanmonstar avatar Jan 09 '24 14:01 seanmonstar

@seanmonstar or perhaps we can point users directly to hyper-util crate for examples? with a note saying hyper itself is for a lower-level usecase

dswij avatar Jan 09 '24 17:01 dswij

What are the objections against exposing support::TokioIo publicly? Having an example which is essentially unusable without depending on a third-party library is very strange, and led to quite a bit of head scratching on my part.

Even though hyper is reactor agnostic, it should have an implementation which works with a rector implementation out of the box. No flexibility is lost, while also allowing new users to Fall into the pit of success

thrawn01 avatar Jun 09 '24 23:06 thrawn01

We provided a simple Tokio runtime implementations in hyper-util.

This is not a third-party library, it's maintained by hyper's maintainers.

dswij avatar Jun 10 '24 06:06 dswij

Thanks, I found it before commenting here. It says This crate is less-stable than hyper, Which doesn't fill me with confidence.

Should we consider it stable and safe to use with hyper 1.0?

thrawn01 avatar Jun 10 '24 06:06 thrawn01

It is safe to use with hyper 1.0.

dswij avatar Jun 10 '24 07:06 dswij