-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for typed task Labels. (#138)
[PR98](#98) added support for associated a single untyped `Tag` with each task and thread. As we've gained experience with Tags, we've increasingly felt a need to have a mechanism that is both better typed, and allows more than one tag to be associated with tasks. This commit introduces `Labels`, which are inspired by `Extensions` in [the http crate](https://docs.rs/http/latest/http/struct.Extensions.html). Users can attach any set of Labels to a task or thread, with the only caveat being that there can be at most one Label for a given type T. This is not too onerous a restriction, since one can use the common [newtype idiom](https://doc.rust-lang.org/rust-by-example/generics/new_types.html) to easily work around this. For tracing, we also provide a newtype `TaskName` that can be converted to and from a `String`. If the `TaskName` label is set for a task, tracing output will show the `TaskName` (in addition to the `TaskId`) to make logs easier to read. Since the current functionality provided by `Tag` is superseded by `Labels`, we also mark `Tag` as deprecated. They will be removed in a future release. Co-authored-by: Rajeev Joshi <{ID}+{username}@users.noreply.github.com>
- Loading branch information
Showing
8 changed files
with
886 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.