subsquid / worker-rs

GNU Affero General Public License v3.0
0 stars 1 forks source link

Handle subtasks gracefully #20

Open kalabukdima opened 1 month ago

kalabukdima commented 1 month ago

There is a common pattern (not only in the worker, but across all our components) which is difficult to describe with safe Rust:

Basically, it's what is called "structured concurrency" The main complication is that to run the subtasks truly in parallel you have to use tokio::spawn which accepts a 'static future (scoped tasks have been removed), making you pass all the shared objects wrapped in Arc.

The task_scope crate looks like a possible solution, but it's very unpopular, so it should be carefully reviewed first.