<commit_before>module ResqueMaster
  class Server
    def subscribe
      mq.queue.subscribe do |_delivery_info, _metadata, payload|
        args = parse_message(payload)
        method = args.shift

        Resque.send(method, *args)
      end
    end

    def run
      puts 'Welcome to ResqueMaster'

      puts 'Loaded plugins:'
      ResqueMaster.plugins.each do |plugin|
        puts " * #{plugin.class.name}"
      end

      load_enviroment
      subscribe

      loop do
        sleep(1)
      end
    rescue Interrupt
      puts 'Goodbye'
    end

    def parse_message(payload)
      Marshal.load(payload)
    end
<commit_msg>Require resque master server to acknowledge received messages<commit_after>module ResqueMaster
  class Server
    def subscribe
      mq.queue.subscribe(ack: true) do |delivery_info, _metadata, payload|
        args = parse_message(payload)
        method = args.shift

        Resque.send(method, *args)

        mq.channel.acknowledge(delivery_info.delivery_tag, false)
      end
    end

    def run
      puts 'Welcome to ResqueMaster'

      puts 'Loaded plugins:'
      ResqueMaster.plugins.each do |plugin|
        puts " * #{plugin.class.name}"
      end

      load_enviroment
      subscribe

      loop do
        sleep(1)
      end
    rescue Interrupt
      puts 'Goodbye'
    end

    def parse_message(payload)
      Marshal.load(payload)
    end

{'fraction_non_alphanumeric': 0.07076483202287348, 'fraction_numerical': 0.0014295925661186562, 'mean_word_length': 2.160270880361174, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6930727', 'n_tokens_mistral': 423, 'n_tokens_neox': 409, 'n_words': 108}