Code Monkey home page Code Monkey logo

Comments (4)

ibraheemdev avatar ibraheemdev commented on May 20, 2024 1

actix_rt::spawn also comes up a lot with those new to async. Many jump to tokio::spawn instead of using actix_rt, and spawning tasks doesn't seem to be covered anywhere in the docs. It might also be useful to re-export it under web::spawn similar to web::block.

I think this points to a broader issue with people assuming that actix-web "just uses tokio", and that all tokio runtime methods should "just work". !Send futures and the ability to use Rc instead of Arc, etc. is also relevant. A runtime section in the docs would probably help.

from actix-website.

JohnTitor avatar JohnTitor commented on May 20, 2024

We should add a note to explain what's actix-rt in brief here. Indeed, it's user-friendly if we have an explanation to add actix-rt to dependencies at least.

from actix-website.

Ben-PH avatar Ben-PH commented on May 20, 2024

Adding an explanation/instruction to add to dependencies would have eliminated my steps 1-4 for sure. My guess is I would not have opened this issue had that been the case. Personal views on what makes for a great tutorial aside, I think that's a strong candidate for "easiest plan to productively close the issue".

If taking my personal views into account, this explanation feels to me like might be introducing actix-rt in a way that abstracts it a bit too much. This would makes sense for some things (such as abstracting away the inner details of printf(3) when first learning C), but I'm not so sure actix-rt is so clear cut. As a 100% newbie, I might be left thinking "this is a new thing. It seems pretty important. It looks like I will have to deal with it in some detail. I need to know more than just 'add it to dependancies'". The effect on me would be to get distracted from the learning-task at hand (not always a bad thing).

Taking that into consideration, something like a link, comment-box, footnote, etc. to briefly explain the role actix-rt plays in the context of /docs/server content, and a promise to the reader that it's covered in later chapters. That way they can "learn only as much as they need to right now, but know where to go for something more in-depth". Without knowing much about actix or actix-rt, I can't comment on what would make a good balance when it comes to how much detail actix-rt needs when being introduced.

from actix-website.

fakeshadow avatar fakeshadow commented on May 20, 2024

@ibraheemdev
"just use tokio" is a path we are taking and more. Take a look at this PR and it's already ready.
actix/actix-net#266 (comment)

I believe we should let user use whatever runtime they want as more as possible and not limiting them to a strict model. (This would not happen right away with a single PR but a general direction we would want to work on).

The problem about !Send is legit as it has not only to do with cost but also compiler issue. (Liking trying to use awc or actix inside tokio::spawn).

I guess the solution could be we mirror tokio when we can and try to support most tokio types/features when we can.

At the same time we want to keep the compat to already established actix-* eco. Documentation should be more specific on the part where a confustion may happen. (Like the awc example mentioned above).

There is a downside with this approach that would be the code base would be more complicated an could give trouble for future maintainers. But in general I believe the async Rust is heading towards a reduction of runtime fragmentation so the task would mostly be removing runtime related code and not adding more to it.

TLDR: we could make actix_rt stuff an opt-in like feature. It's there and if it's already used it's just like that. We encourage new comers to use whatever they like and only when they try to use actix-* crates in a specific way and/or after high perf/low overhead we guide them to use actix_rt(or counterpart of the same runtime feature of something like tokio, async_std)

from actix-website.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.