pub struct TaskTree { /* private fields */ }
Implementations
sourceimpl TaskTree
impl TaskTree
pub fn new() -> Arc<Self>
pub fn set_force_flush(&self, enabled: bool)
pub fn force_flush_enabled(&self) -> bool
pub fn create_task(self: &Arc<Self>, name: &str) -> Task
pub fn add_reporter(&self, reporter: Arc<dyn Reporter>)
pub fn spawn_sync<F, T>(
self: &Arc<Self>,
name: String,
f: F,
parent: Option<UniqID>
) -> Result<T>where
F: FnOnce(Task) -> Result<T>,
T: Send,
pub fn create_task_internal<S: Into<String>>(
self: &Arc<Self>,
name: S,
parent: Option<UniqID>
) -> UniqID
pub fn mark_done(&self, id: UniqID, error_message: Option<String>)
pub fn add_data<S: Into<String>, D: Into<DataValue>>(
&self,
id: UniqID,
key: S,
value: D
)
pub fn get_data<S: Into<String>>(&self, id: UniqID, key: S) -> Option<DataValue>
sourcepub fn hide_errors_default_msg<S: Into<String>>(&self, msg: Option<S>)
pub fn hide_errors_default_msg<S: Into<String>>(&self, msg: Option<S>)
Reporters can use this flag to choose to not report errors. This is useful for cases where there’s a large task chain and every single task reports a partial errors (that gets built up with each task) It would make sense to report it only once at the top level (thrift request, cli call, etc) and only mark other tasks. If set to Some, the message inside is what would be reported by default instead of reporting errors to avoid confusion (e.g. “error was hidden, see …”)
sourcepub fn attach_transitive_data_to_errors_default(&self, val: bool)
pub fn attach_transitive_data_to_errors_default(&self, val: bool)
When errors occur, we attach task data to it in the description. If set to false, only task direct data will be attached and not transitive data. This is useful sometimes to remove the noise of transitive data appearing in every error in the chain (e.g. hostname)
sourcepub fn set_error_formatter(
&self,
error_formatter: Option<Arc<dyn ErrorFormatter>>
)
pub fn set_error_formatter(
&self,
error_formatter: Option<Arc<dyn ErrorFormatter>>
)
Add a custom error formatter to change how error messages look in
reporters.
Unfortunately it is not configurable per reporter, because errors
normally don’t implement Clone
and it will be almost impossible to add
reference counters to all errors in all chains
sourcepub fn add_data_transitive<S: Into<String>, D: Into<DataValue>>(
&self,
key: S,
value: D
)
pub fn add_data_transitive<S: Into<String>, D: Into<DataValue>>(
&self,
key: S,
value: D
)
Add transitive data to the task tree. This transitive data will be added to every task created in this task tree
pub fn task_progress(&self, id: UniqID, done: i64, total: i64)
sourcepub fn maybe_force_flush(&self)
pub fn maybe_force_flush(&self)
If force_flush set to true, this function will block the thread until everything is reported. Useful for cases when the process exits before all async events are reported and stuff is missing from stdout.