<commit_before>import Identity from '../auth/identity';
import Schedule from './schedule';
import CommandFailure, { Retry, Cancel } from './commandFailure';

export default class RabbitScheduler {

  constructor({ channel, clock, deliverer }) {
    this.channel = channel;
    this.clock = clock;
    this.deliverer = deliverer;

    const q = 'scheduledCommands';
    channel.assertQueue(q, { durable: true }).then(() =>
      channel.consume(q, async message => {
        const command = JSON.parse(message.content);
        await this.deliver(command)
          .then(() => {
            channel.ack(message);
          })
          .catch(async error => {
            let failure = new CommandFailure({ error, command });
            if (error.handler) {
              await error.handler.handleDeliveryError(failure, error.aggregate);
            }
            channel.nack(message, false, failure.failureAction instanceof Retry && !message.fields.redelivered);
          });
      })
    );<commit_msg>Fix DeepScan error.<commit_after>import Identity from '../auth/identity';
import Schedule from './schedule';
import CommandFailure, { Retry } from './commandFailure';

export default class RabbitScheduler {

  constructor({ channel, clock, deliverer }) {
    this.channel = channel;
    this.clock = clock;
    this.deliverer = deliverer;

    const q = 'scheduledCommands';
    channel.assertQueue(q, { durable: true }).then(() =>
      channel.consume(q, async message => {
        const command = JSON.parse(message.content);
        await this.deliver(command)
          .then(() => {
            channel.ack(message);
          })
          .catch(async error => {
            let failure = new CommandFailure({ error, command });
            if (error.handler) {
              await error.handler.handleDeliveryError(failure, error.aggregate);
            }
            channel.nack(message, false, failure.failureAction instanceof Retry && !message.fields.redelivered);
          });
      })
    );
{'fraction_non_alphanumeric': 0.12810327706057598, 'fraction_numerical': 0.0, 'mean_word_length': 2.46815834767642, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5513374', 'n_tokens_mistral': 529, 'n_tokens_neox': 528, 'n_words': 129}