🌐
Docs.rs
docs.rs › tokio › latest › tokio › sync › mpsc › index.html
tokio::sync::mpsc - Rust
A multi-producer, single-consumer queue for sending values between asynchronous tasks.
🌐
Rust Programming Language
users.rust-lang.org › help
Axum / tokio shared state channel confusion - help - The Rust Programming Language Forum
November 13, 2021 - I seem to have a conflict between sharing state in Axum, and using a tokio::sync channel rather than a std:sync channel. Tokio says I should be using a tokio::sync channel to communicate between synchronous and asynchronous code ( I understand because it's wrong to block in sync code ). However ...
🌐
Docs.rs
docs.rs › axum › latest › axum
axum - Rust
Router is used to set up which paths go to which services: use axum::{Router, routing::get}; // our router let app = Router::new() .route("/", get(root)) .route("/foo", get(get_foo).post(post_foo)) .route("/foo/bar", get(foo_bar)); // which calls one of these handlers async fn root() {} async ...
🌐
Understand Axum
rust-api.dev › docs › part-1 › tokio-hyper-axum
Understand Axum | rust-api.dev
May 1, 2021 - In this chapter you will acquire ... of the Axum, Tower and Hyper crates, these are the libraries underlying our application server. Your will learn how to compose middleware layers to add cross-cutting features to your API endpoints. ... Our web application will be completely based on the tokio.rs family ...
🌐
Reddit
reddit.com › r/rust › tokio's axum web framework - not new, but new to me
r/rust on Reddit: Tokio's Axum web framework - not new, but new to me
January 22, 2022 - 148 votes, 33 comments. 348K subscribers in the rust community. A place for all things related to the Rust programming language—an open-source systems language that emphasizes performance, reliability, and productivity.
🌐
GitHub
github.com › tokio-rs › axum
GitHub - tokio-rs/axum: Ergonomic and modular web framework built with Tokio, Tower, and Hyper
axum is a relatively thin layer on top of hyper and adds very little overhead. So axum's performance is comparable to hyper. You can find benchmarks here and here. This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in 100% safe Rust.
Starred by 22.2K users
Forked by 1.2K users
Languages: Rust
🌐
Tokio
tokio.rs › blog › 2021-07-announcing-axum
Announcing Axum | Tokio - An asynchronous Rust runtime
Tokio is a runtime for writing reliable asynchronous applications with Rust. It provides async I/O, networking, scheduling, timers, and more.
🌐
Tokio
tokio.rs › tokio › tutorial › channels
Channels | Tokio - An asynchronous Rust runtime
The mpsc channel is used to send commands to the task managing the redis connection. The multi-producer capability allows messages to be sent from many tasks. Creating the channel returns two values, a sender and a receiver. The two handles are used separately.
🌐
Tokio
tokio.rs › tokio › topics › shutdown
Graceful Shutdown | Tokio - An asynchronous Rust runtime
use tokio::signal; use tokio::sync::mpsc; #[tokio::main] async fn main() { let (shutdown_send, mut shutdown_recv) = mpsc::unbounded_channel(); // ... spawn application as separate task ... // // application uses shutdown_send in case a shutdown was issued from inside // the application ...
Find elsewhere
🌐
Rust-classes
rust-classes.com › chapter_6_4
Sharing data through channels - Rust Development Classes
As you can see, the users list does not need to be wrapped in a Mutex. This is because the main thread is the only thread that is manipulating the users Vec. The lookup_user() function is returning the User through the Sender half of the mpsc::channel.
🌐
GitHub
github.com › tokio-rs › axum › discussions › 1911
Is State cloned for each request? · tokio-rs/axum · Discussion #1911

Yes the state is cloned for each request. Otherwise you wouldn't be able to extract an owned state.

Author: tokio-rs
🌐
Rust Programming Language
users.rust-lang.org › help
Sharing / Sending Data between Tasks within an Axum Framework - help - The Rust Programming Language Forum
March 30, 2023 - Hi, I am trying to create a micro-service in rust. Currently, I am using Axum. This micro-service actually only take's 1 type of request (a Post request with JSON). However, this service is extremely IO intensive, as in I am web-scraping from 1 particular source which would mean I'd have to ...
🌐
Reddit
reddit.com › r/rust › optimizing a http request batching servce (axum & mpsc)
r/rust on Reddit: Optimizing a HTTP Request batching servce (Axum & MPSC)

I don't know the specifics of your problem, but I'd probably approach this with two separate tasks and an actual external queue using e.g. redis streams. Have one task that answers the request and queues it into the stream, then another task that takes from the stream and forwards / does whatever you intend to do with the batch.

🌐
Reddit
reddit.com › r/rust › new tokio blog post: announcing axum 0.6.0
r/rust on Reddit: New Tokio blog post: Announcing axum 0.6.0
November 25, 2022 - 618 votes, 45 comments. 346K subscribers in the rust community. A place for all things related to the Rust programming language—an open-source…
🌐
Reddit
reddit.com › r/rust › multi-threaded task queue with axum
r/rust on Reddit: Multi-threaded task queue with Axum

I've been working on async actors with axum and I've found using tokio channels (broadcast/mpsc) to be pretty nice. You could keep a list of receivers in some shared state and then have the GET endpoint stream the events from the running tasks through. I don't have a great idea to avoid locking while writing to the shared state though... I just figure it's fairly fast to write so it shouldn't cause too much contention.

🌐
Reddit
reddit.com › r/rust › how to build a "transactional mpsc channel" in tokio?
r/rust on Reddit: How to build a "transactional mpsc channel" in tokio?

let the type you send over the mpsc contain a oneshot and use this oneshot to notify sender that the message has been handled.

🌐
GitHub
github.com › tokio-rs › axum › discussions › 1159
Question: Multiple concurrent writes to a SplitSink · tokio-rs/axum · Discussion #1159
Following from the websocket chat example provided, we are able to receive messages and send messages independent of each other. My currently use-case would need to take this a step further, where ...
Author: tokio-rs
🌐
Hacker News
news.ycombinator.com › item
Rust does not have to be this hard. Most of the pain here come from the unholy t... | Hacker News
Most of the pain here come from the unholy trifactor: combining async, lifetimes and dynamic dispatch with trait object closures; which is indeed very awkward in practice · Async support is incredibly half-baked. It was released as an MVP, but that MVP has not improved notably in almost three years
🌐
Reddit
reddit.com › r/rust › ask /r/rust: building a typosquatting service that scales using tokio + axum
r/rust on Reddit: Ask /r/rust: building a typosquatting service that scales using Tokio + Axum

If your library function is blocking, try running it inside tokio::spwan_blocking function, and use mpsc channels to communicate. Since looks like you are blocking your async runtime. This just my guess, will have to check the full code tho.

🌐
Reddit
reddit.com › r/rust › tachyonix: a very fast mpsc async bounded channel
r/rust on Reddit: Tachyonix: a very fast MPSC async bounded channel

Looks great, thank you for releasing it as a standalone crate! I'm happy to see an in-depth discussion of the trade-offs between various implementations. Does it use fences or inline assembly for synchronization? I'm asking because they usually cause false positives on Thread Sanitizer , which is my go-to tool for testing concurrency because you can run entire real-world programs with it with reasonable performance (unlike loom or miri).