function execute() {
  // Get queueStats from redis
  let keyArray;
  const mainKey = 'queueStats';
  return client.hgetallAsync(mainKey).then((reply) => {
    const currentTimeStamp = 'queueStats.' + createTimeStamp();
    if (reply) {
      const keys = stringToArray(reply.keyArray);
      for (let i = 0; i < keys.length; i++) {
        if (currentTimeStamp !== keys[i]) {
          // Get data based on key from redis
          client.hgetallAsync(keys[i]).then((data) => {
            if (data) {
              // Construct log object
              const queueStats = constructLogObject(data);

              // If 95th Percentile time is higher then limit then
              // print warn log else info log
              if (queueTime95thMillis &&
                queueStats.queueTime95thMillis > queueTime95thMillis) {
                activityLogUtil
                  .printActivityLogString(queueStats, 'queueStats', 'warn');
              } else {
                activityLogUtil
                  .printActivityLogString(queueStats, 'queueStats', 'info');
              }

              // Delete key once logs is printed
              client.del(keys[i]);
            }
          })
          .catch((err) => {
            throw new Error(err);
          });
        } else {
          // reset key value to contain only current timestamp key
          keyArray = currentTimeStamp;
        }
      }

      const hmsetObj = {
        keyArray: addToArray('', keyArray),
      };
      logInvalidHmsetValues(mainKey, hmsetObj);
      client.hmset(mainKey, hmsetObj);
    }
  })
  .catch((_err) => {
    throw new Error(_err);
  });
} // execute
/**
 * Execute the call to write queue stats activity logs.
 */
Execute the call to write queue stats activity logs.
Execute the call to write queue stats activity logs .
function execute() {
  let keyArray;
  const mainKey = 'queueStats';
  return client.hgetallAsync(mainKey).then((reply) => {
    const currentTimeStamp = 'queueStats.' + createTimeStamp();
    if (reply) {
      const keys = stringToArray(reply.keyArray);
      for (let i = 0; i < keys.length; i++) {
        if (currentTimeStamp !== keys[i]) {
          client.hgetallAsync(keys[i]).then((data) => {
            if (data) {
              const queueStats = constructLogObject(data);
              if (queueTime95thMillis &&
                queueStats.queueTime95thMillis > queueTime95thMillis) {
                activityLogUtil
                  .printActivityLogString(queueStats, 'queueStats', 'warn');
              } else {
                activityLogUtil
                  .printActivityLogString(queueStats, 'queueStats', 'info');
              }
              client.del(keys[i]);
            }
          })
          .catch((err) => {
            throw new Error(err);
          });
        } else {
          keyArray = currentTimeStamp;
        }
      }
      const hmsetObj = {
        keyArray: addToArray('', keyArray),
      };
      logInvalidHmsetValues(mainKey, hmsetObj);
      client.hmset(mainKey, hmsetObj);
    }
  })
  .catch((_err) => {
    throw new Error(_err);
  });
} 
function execute ( ) { let keyArray ; const mainKey = 'queueStats' ; return client . hgetallAsync ( mainKey ) . then ( ( reply ) => { const currentTimeStamp = 'queueStats.' + createTimeStamp ( ) ; if ( reply ) { const keys = stringToArray ( reply . keyArray ) ; for ( let i = 0 ; i < keys . length ; i ++ ) { if ( currentTimeStamp !== keys [ i ] ) { client . hgetallAsync ( keys [ i ] ) . then ( ( data ) => { if ( data ) { const queueStats = constructLogObject ( data ) ; if ( queueTime95thMillis && queueStats . queueTime95thMillis > queueTime95thMillis ) { activityLogUtil . printActivityLogString ( queueStats , 'queueStats' , 'warn' ) ; } else { activityLogUtil . printActivityLogString ( queueStats , 'queueStats' , 'info' ) ; } client . del ( keys [ i ] ) ; } } ) . catch ( ( err ) => { throw new Error ( err ) ; } ) ; } else { keyArray = currentTimeStamp ; } } const hmsetObj = { keyArray : addToArray ( '' , keyArray ) , } ; logInvalidHmsetValues ( mainKey , hmsetObj ) ; client . hmset ( mainKey , hmsetObj ) ; } } ) . catch ( ( _err ) => { throw new Error ( _err ) ; } ) ; }
Execute the call to write queue stats activity logs.
Execute the call to write queue stats activity logs .
// Get queueStats from redis // Get data based on key from redis // Construct log object // If 95th Percentile time is higher then limit then // print warn log else info log // Delete key once logs is printed // reset key value to contain only current timestamp key // execute