Open
Description
I've started using tokio-metrics
at work recently and found it a bit unfortunate that if you put TaskMonitor
s in static
s, you have to wrap them in LazyLock
or similar for the initialization. It seems the only reason for this is that TaskMonitor
is internally an Arc
for easy cloning, but it doesn't seem like there is any need for that.
How about an API like this for construction?
// no Clone impl
pub struct TaskMonitor {
// all the atomics currently found in the inner state type
}
impl TaskMonitor {
pub fn new() -> Arc<Self> { /* ... */ }
pub const fn new_static() -> Self { /* ... */ }
pub const fn builder() -> TaskMonitorBuilder { /* ... */ }
}
pub struct TaskMonitorBuilder {
// same as now
}
impl TaskMonitorBuilder {
// with_* methods just like before
pub fn build(self) -> Arc<TaskMonitor> { /* ... */ }
pub const fn build_static(self) -> TaskMonitor { /* ... */ }
}
Metadata
Metadata
Assignees
Labels
No labels