From 8aed2c4d41ef4e7a6a128062676382a1659f43d4 Mon Sep 17 00:00:00 2001 From: Gil Desmarais Date: Fri, 9 Aug 2024 19:49:15 +0200 Subject: [PATCH] feat: use parallel processing for feed retrieval in health_check.rb Closes #560. --- Gemfile | 1 + Gemfile.lock | 1 + app/health_check.rb | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 65aefa7..d0342d3 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,7 @@ gem 'html2rss-configs', github: 'html2rss/html2rss-configs' # gem 'html2rss-configs', path: '../html2rss-configs' gem 'erubi' +gem 'parallel' gem 'rack-cache' gem 'rack-timeout' gem 'rack-unreloader' diff --git a/Gemfile.lock b/Gemfile.lock index e4a7acb..d3653a1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -150,6 +150,7 @@ DEPENDENCIES erubi html2rss html2rss-configs! + parallel puma rack-cache rack-timeout diff --git a/app/health_check.rb b/app/health_check.rb index 9a363b6..f0c5609 100644 --- a/app/health_check.rb +++ b/app/health_check.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'parallel' + require_relative 'local_config' module App @@ -44,7 +46,7 @@ def run # @return [Array] def errors [].tap do |errors| - LocalConfig.feed_names.each do |feed_name| + Parallel.each(LocalConfig.feed_names, in_threads: 4) do |feed_name| Html2rss.feed_from_yaml_config(LocalConfig::CONFIG_FILE, feed_name.to_s).to_s rescue StandardError => e errors << "[#{feed_name}] #{e.class}: #{e.message}"