feat: add spawn_with_name#20
Conversation
Allows using unstable tokio feature when enabled to name tasks spawned.
|
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/n0-future/pr/20/docs/n0_watcher/ Last updated: 2025-12-01T21:39:52Z |
matheus23
left a comment
There was a problem hiding this comment.
Love this.
Would love to eventually remove other spawn variants in favor of only having named ones, in an effort to "standardize on a style" in a way with n0-future.
| tokio::task::Builder::new() | ||
| .name(name) | ||
| .spawn(future) | ||
| .expect("doesn't fails") |
There was a problem hiding this comment.
| .expect("doesn't fails") | |
| .expect("doesn't fail") |
There was a problem hiding this comment.
Maybe nice if it says why it doesn't fail.
There was a problem hiding this comment.
because I looked at the implementation 🤷 not sure what else to say
There was a problem hiding this comment.
what the...
Okay maybe sth like "impl doesn't fail".
|
I'm going to be dissenting. I think we should adopt the let task = n0_future::task::Builder::new()
.name("actor")
.instrument() // by default .span() is set to info_span(name)
.span(tracing::info_span!("my-actor", field="value"))
.spawn(n0_future::future::ready(true));
// or a shorthand for the same without customising the span
let task = n0_futrue::task::Builder::with_name("actor")
.instrument()
.spawn(n0_future::future::ready(true)); |
Compared to |
We already require folks to remember to use |
fair, that |
|
I'm thinking of cutting another release of this given the recent PRs merged. Should we attempt to get this into the release as well? |
|
I thought more about the suggestion from @flub, so I would like to hold off on this, and experiment with a builder approach some more. |
matheus23
left a comment
There was a problem hiding this comment.
Let's experiment with a builder-like approach first.
Allows using unstable tokio feature when enabled to name tasks spawned.