-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add spawn_with_name
#20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .expect("doesn't fails") | |
| .expect("doesn't fail") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe nice if it says why it doesn't fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because I looked at the implementation 🤷 not sure what else to say
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's experiment with a builder-like approach first.
Allows using unstable tokio feature when enabled to name tasks spawned.