async fn invoke_task_function(
    function: &SwanlingTaskFunction,
    thread_user: &SwanlingUser,
    thread_task_index: usize,
    thread_task_name: &str,
) -> Result<(), flume::SendError<Option<SwanlingLog>>> {
    let started = time::Instant::now();
    let mut raw_task = SwanlingTaskMetric::new(
        thread_user.started.elapsed().as_millis(),
        thread_user.task_sets_index,
        thread_task_index,
        thread_task_name.to_string(),
        thread_user.weighted_users_index,
    );
    let success = function(&thread_user).await.is_ok();
    raw_task.set_time(started.elapsed().as_millis(), success);

    // Exit if all metrics or task metrics are disabled.
    if thread_user.config.no_metrics || thread_user.config.no_task_metrics {
        return Ok(());
    }

    // If tasks-file is enabled, send a copy of the raw task metric to the logger thread.
    if !thread_user.config.task_log.is_empty() {
        if let Some(logger) = thread_user.logger.as_ref() {
            logger.send(Some(SwanlingLog::Task(raw_task.clone())))?;
        }
    }

    // Otherwise send metrics to parent.
    if let Some(parent) = thread_user.channel_to_parent.clone() {
        // Best effort metrics.
        let _ = parent.send(SwanlingMetric::Task(raw_task));
    }

    Ok(())
}
// Invoke the task function, collecting task metrics.
Invoke the task function, collecting task metrics.
Invoke the task function collecting task metrics .
async fn invoke_task_function(
    function: &SwanlingTaskFunction,
    thread_user: &SwanlingUser,
    thread_task_index: usize,
    thread_task_name: &str,
) -> Result<(), flume::SendError<Option<SwanlingLog>>> {
    let started = time::Instant::now();
    let mut raw_task = SwanlingTaskMetric::new(
        thread_user.started.elapsed().as_millis(),
        thread_user.task_sets_index,
        thread_task_index,
        thread_task_name.to_string(),
        thread_user.weighted_users_index,
    );
    let success = function(&thread_user).await.is_ok();
    raw_task.set_time(started.elapsed().as_millis(), success);
    // Exit if all metrics or task metrics are disabled.
    if thread_user.config.no_metrics || thread_user.config.no_task_metrics {
        return Ok(());
    }
    // If tasks-file is enabled, send a copy of the raw task metric to the logger thread.
    if !thread_user.config.task_log.is_empty() {
        if let Some(logger) = thread_user.logger.as_ref() {
            logger.send(Some(SwanlingLog::Task(raw_task.clone())))?;
        }
    }
    // Otherwise send metrics to parent.
    if let Some(parent) = thread_user.channel_to_parent.clone() {
        // Best effort metrics.
        let _ = parent.send(SwanlingMetric::Task(raw_task));
    }
    Ok(())
}
async fn invoke_task_function ( function : & SwanlingTaskFunction , thread_user : & SwanlingUser , thread_task_index : usize , thread_task_name : & str , ) -> Result < ( ) , flume :: SendError < Option < SwanlingLog > > > { let started = time :: Instant :: now ( ) ; let mut raw_task = SwanlingTaskMetric :: new ( thread_user . started . elapsed ( ) . as_millis ( ) , thread_user . task_sets_index , thread_task_index , thread_task_name . to_string ( ) , thread_user . weighted_users_index , ) ; let success = function ( & thread_user ) . await . is_ok ( ) ; raw_task . set_time ( started . elapsed ( ) . as_millis ( ) , success ) ; // Exit if all metrics or task metrics are disabled. if thread_user . config . no_metrics || thread_user . config . no_task_metrics { return Ok ( ( ) ) ; } // If tasks-file is enabled, send a copy of the raw task metric to the logger thread. if ! thread_user . config . task_log . is_empty ( ) { if let Some ( logger ) = thread_user . logger . as_ref ( ) { logger . send ( Some ( SwanlingLog :: Task ( raw_task . clone ( ) ) ) ) ? ; } } // Otherwise send metrics to parent. if let Some ( parent ) = thread_user . channel_to_parent . clone ( ) { // Best effort metrics. let _ = parent . send ( SwanlingMetric :: Task ( raw_task ) ) ; } Ok ( ( ) ) }
Invoke the task function, collecting task metrics.
Invoke the task function collecting task metrics .
function
&SwanlingTaskFunction
thread_user
&SwanlingUser
thread_task_index
usize
thread_task_name
&str