diff options
author | Alex Auvolat <alex@adnab.me> | 2022-06-21 17:18:16 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-06-21 17:18:16 +0200 |
commit | 10c886111e304a53be24b29194f2127d91121929 (patch) | |
tree | bd61e98beeccfe338c1ae41a8c1322493f618dd2 /src/garage/cli/util.rs | |
parent | 14337d2a561887b94ea165727dd49263717cb478 (diff) | |
download | garage-10c886111e304a53be24b29194f2127d91121929.tar.gz garage-10c886111e304a53be24b29194f2127d91121929.zip |
Rename things, garage worker list cmd
Diffstat (limited to 'src/garage/cli/util.rs')
-rw-r--r-- | src/garage/cli/util.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/garage/cli/util.rs b/src/garage/cli/util.rs index 329e8a3e..81361864 100644 --- a/src/garage/cli/util.rs +++ b/src/garage/cli/util.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; +use garage_util::background::*; use garage_util::crdt::*; use garage_util::data::Uuid; use garage_util::error::*; @@ -235,3 +236,26 @@ pub fn find_matching_node( Ok(candidates[0]) } } + +pub fn print_worker_info(wi: HashMap<usize, WorkerInfo>) { + let mut wi = wi.into_iter().collect::<Vec<_>>(); + wi.sort_by_key(|(tid, info)| { + ( + match info.status { + WorkerStatus::Busy => 0, + WorkerStatus::Idle => 1, + WorkerStatus::Done => 2, + }, + *tid, + ) + }); + + let mut table = vec![]; + for (tid, info) in wi.iter() { + table.push(format!("{}\t{:?}\t{}", tid, info.status, info.name)); + if let Some(i) = &info.info { + table.push(format!("\t\t{}", i)); + } + } + format_table(table); +} |