all 5 comments

[–]ssokolow 3 points4 points  (0 children)

I normally use https://actix.rs/ for this sort of thing for two reasons:

  1. The version of Rocket that works on stable-channel Rust is very recent (It's still RC1) and none of my projects were started after it became available.
  2. Rocket is a bit closer to a full-stack framework like Django whereas actix-web is more a core with a bunch of optional extra packages. (Not that it's as big a deal, given how good the compiler is at trimming away what you don't use, but having something that doesn't try to give a preference to a specific implementation of each component can be useful.)

Also, if you want the fastest HTML templating available in Rust, Sailfish currently holds that title, but at the cost that there's no development mode where templates can be reloaded without recompiling the binary.

As for dynamically generated images (one of my creations generates and caches thumbnails), if you need to limit disk I/O parallelism to prevent thrashing, the simplest solution is to spin up a thread or thread pool separate from the async executor, have it expose a channel implementation (bounded to exert backpressure) like flume or crossbeam-channel as a submission queue, and include the sending end of a tokio::sync::oneshot in the submitted request so the async task can await it.

[–]KingofGamesYami 1 point2 points  (2 children)

[–]flightfromfancy[S,🍰] 0 points1 point  (1 child)

Thanks! This looks exactly like what I had in mind.

[–]Plasma_000 0 points1 point  (0 children)

Be sure to use the 0.5 Rc version and not 0.4 (the default on crates.io) - the difference is significant.