pub(crate) async fn loop_operate_logs(pool: Arc<db::ConnectionPool>) {
    loop {
        let mut operation_log_pairs: Vec<NewOperationLogPair> = Vec::new();

        'logs_collection: for _ in 0..512 {
            let logs_future: TokioTimeout<_> =
                tokio_timeout(Duration::from_secs(3), OPERATION_LOG_CONSUMERS.1.recv());

            match logs_future.await {
                // No new events and timeout.
                Err(_) => break 'logs_collection,
                // Internal runtime exception.
                Ok(Err(_)) => {
                    return;
                }
                Ok(Ok(log_pair)) => {
                    operation_log_pairs.push(log_pair);
                }
            }
        }

        if operation_log_pairs.is_empty() {
            continue;
        }

        if let Ok(conn) = pool.get() {
            operate_logs(conn, operation_log_pairs)
                .await
                .map_err(|e| error!("operate-logs: {}", e))
                .ok();
            continue;
        }

        error!(target:"loop-operate-logs", "No available database connection.");
    }
}
// Operation log asynchronous consumer
//
// The user's operations in the system are logged to track,
// But in order not to affect the performance of the system,
// These logs go through the channel with the asynchronous state machine to consume.
Operation log asynchronous consumer
The user's operations in the system are logged to track,
But in order not to affect the performance of the system,
These logs go through the channel with the asynchronous state machine to consume.
Operation log asynchronous consumer The user ' s operations in the system are logged to track But in order not to affect the performance of the system These logs go through the channel with the asynchronous state machine to consume .
pub(crate) async fn loop_operate_logs(pool: Arc<db::ConnectionPool>) {
    loop {
        let mut operation_log_pairs: Vec<NewOperationLogPair> = Vec::new();
        'logs_collection: for _ in 0..512 {
            let logs_future: TokioTimeout<_> =
                tokio_timeout(Duration::from_secs(3), OPERATION_LOG_CONSUMERS.1.recv());
            match logs_future.await {
                // No new events and timeout.
                Err(_) => break 'logs_collection,
                // Internal runtime exception.
                Ok(Err(_)) => {
                    return;
                }
                Ok(Ok(log_pair)) => {
                    operation_log_pairs.push(log_pair);
                }
            }
        }
        if operation_log_pairs.is_empty() {
            continue;
        }
        if let Ok(conn) = pool.get() {
            operate_logs(conn, operation_log_pairs)
                .await
                .map_err(|e| error!("operate-logs: {}", e))
                .ok();
            continue;
        }
        error!(target:"loop-operate-logs", "No available database connection.");
    }
}
pub ( crate ) async fn loop_operate_logs ( pool : Arc < db :: ConnectionPool > ) { loop { let mut operation_log_pairs : Vec < NewOperationLogPair > = Vec :: new ( ) ; ' logs_collection : for _ in 0 .. 512 { let logs_future : TokioTimeout < _ > = tokio_timeout ( Duration :: from_secs ( 3 ) , OPERATION_LOG_CONSUMERS . 1 . recv ( ) ) ; match logs_future . await { // No new events and timeout. Err ( _ ) => break ' logs_collection , // Internal runtime exception. Ok ( Err ( _ ) ) => { return ; } Ok ( Ok ( log_pair ) ) => { operation_log_pairs . push ( log_pair ) ; } } } if operation_log_pairs . is_empty ( ) { continue ; } if let Ok ( conn ) = pool . get ( ) { operate_logs ( conn , operation_log_pairs ) . await . map_err ( | e | error ! ( " " e ) ) . ok ( ) ; continue ; } error ! ( target " " " " ) ; } }
Operation log asynchronous consumer
The user's operations in the system are logged to track,
But in order not to affect the performance of the system,
These logs go through the channel with the asynchronous state machine to consume.
Operation log asynchronous consumer The user ' s operations in the system are logged to track But in order not to affect the performance of the system These logs go through the channel with the asynchronous state machine to consume .
pool
Arc<db::ConnectionPool>
pool
Arc<db::ConnectionPool>