use prometheus_client::encoding::{EncodeLabelSet, EncodeLabelValue};
#[derive(Clone, Debug, Hash, PartialEq, Eq, EncodeLabelSet)]
pub struct Label {
name: String,
kind: Kind,
execution: Execution,
}
impl Label {
pub const fn root() -> Self {
Self {
name: String::new(),
kind: Kind::Root,
execution: Execution::Shared,
}
}
pub const fn task(name: String, execution: crate::Execution) -> Self {
Self {
name,
kind: Kind::Task,
execution: match execution {
crate::Execution::Dedicated => Execution::Dedicated,
crate::Execution::Shared(blocking) => {
if blocking {
Execution::SharedBlocking
} else {
Execution::Shared
}
}
},
}
}
pub fn name(&self) -> String {
self.name.clone()
}
}
#[derive(Clone, Debug, Hash, PartialEq, Eq, EncodeLabelValue)]
pub enum Kind {
Root,
Task,
}
#[derive(Clone, Debug, Hash, PartialEq, Eq, EncodeLabelValue)]
pub enum Execution {
Shared,
SharedBlocking,
Dedicated,
}