Skip to content

Commit

Permalink
refactor: rename to SelfWakes
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
  • Loading branch information
Rustin170506 committed Nov 29, 2023
1 parent c3eae4f commit d161904
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,16 @@ Options:
Each linter is specified by its name, which is one of:
* `self-wake-percent` -- Warns when a task wakes itself more
than a certain percentage of its total wakeups.
* `self-wakes` -- Warns when a task wakes itself more than a
certain percentage of its total wakeups.
* `lost-waker` -- Warns when a task is dropped without being
woken.
* `never-yielded` -- Warns when a task has never yielded.
[default: self-wake-percent lost-waker never-yielded]
[possible values: self-wake-percent, lost-waker,
never-yielded]
[default: self-wakes lost-waker never-yielded]
[possible values: self-wakes, lost-waker, never-yielded]
--log-dir <LOG_DIRECTORY>
Path to a directory to write the console's internal logs to.
Expand Down
2 changes: 1 addition & 1 deletion tokio-console/console.example.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
default_target_addr = 'http://127.0.0.1:6669/'
log = 'off'
linters = [
'self-wake-percent',
'self-wakes',
'lost-waker',
'never-yielded',
]
Expand Down
14 changes: 6 additions & 8 deletions tokio-console/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ pub struct Config {
///
/// Each linter is specified by its name, which is one of:
///
/// * `self-wake-percent` -- Warns when a task wakes itself more than a certain percentage of its total wakeups.
/// * `self-wakes` -- Warns when a task wakes itself more than a certain percentage of its total wakeups.
///
/// * `lost-waker` -- Warns when a task is dropped without being woken.
///
/// * `never-yielded` -- Warns when a task has never yielded.
///
#[clap(long = "linters", value_delimiter = ',', num_args = 1..)]
#[clap(default_values_t = vec![
KnownWarnings::SelfWakePercent,
KnownWarnings::SelfWakes,
KnownWarnings::LostWaker,
KnownWarnings::NeverYielded
])]
Expand Down Expand Up @@ -124,17 +124,15 @@ pub struct Config {
#[derive(clap::ValueEnum, Clone, Debug, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord)]
#[serde(rename_all = "kebab-case")]
pub(crate) enum KnownWarnings {
SelfWakePercent,
SelfWakes,
LostWaker,
NeverYielded,
}

impl From<&KnownWarnings> for warnings::Linter<Task> {
fn from(warning: &KnownWarnings) -> Self {
match warning {
KnownWarnings::SelfWakePercent => {
warnings::Linter::new(warnings::SelfWakePercent::default())
}
KnownWarnings::SelfWakes => warnings::Linter::new(warnings::SelfWakePercent::default()),
KnownWarnings::LostWaker => warnings::Linter::new(warnings::LostWaker),
KnownWarnings::NeverYielded => warnings::Linter::new(warnings::NeverYielded::default()),
}
Expand All @@ -144,7 +142,7 @@ impl From<&KnownWarnings> for warnings::Linter<Task> {
impl fmt::Display for KnownWarnings {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
KnownWarnings::SelfWakePercent => write!(f, "self-wake-percent"),
KnownWarnings::SelfWakes => write!(f, "self-wakes"),
KnownWarnings::LostWaker => write!(f, "lost-waker"),
KnownWarnings::NeverYielded => write!(f, "never-yielded"),
}
Expand Down Expand Up @@ -504,7 +502,7 @@ impl Default for Config {
filter::Targets::new().with_default(filter::LevelFilter::OFF),
)),
linters: vec![
KnownWarnings::SelfWakePercent,
KnownWarnings::SelfWakes,
KnownWarnings::LostWaker,
KnownWarnings::NeverYielded,
],
Expand Down
9 changes: 4 additions & 5 deletions tokio-console/tests/cli-ui.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,16 @@ Options:

Each linter is specified by its name, which is one of:

* `self-wake-percent` -- Warns when a task wakes itself more
than a certain percentage of its total wakeups.
* `self-wakes` -- Warns when a task wakes itself more than a
certain percentage of its total wakeups.

* `lost-waker` -- Warns when a task is dropped without being
woken.

* `never-yielded` -- Warns when a task has never yielded.

[default: self-wake-percent lost-waker never-yielded]
[possible values: self-wake-percent, lost-waker,
never-yielded]
[default: self-wakes lost-waker never-yielded]
[possible values: self-wakes, lost-waker, never-yielded]

--log-dir <LOG_DIRECTORY>
Path to a directory to write the console's internal logs to.
Expand Down

0 comments on commit d161904

Please sign in to comment.