<commit_before>﻿using System;
using System.Collections.Concurrent;
using System.Threading.Tasks;
using OhadSoft.AzureLetsEncrypt.Renewal.Management;
using OhadSoft.AzureLetsEncrypt.Renewal.WebJob.Email;
using OhadSoft.AzureLetsEncrypt.Renewal.WebJob.Telemetry;
using OhadSoft.AzureLetsEncrypt.Renewal.WebJob.Util;

namespace OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings
{
    internal class AppSettingsRenewer
    {
        private readonly IRenewalManager m_renewalManager;
        private readonly IAppSettingsRenewalParamsReader m_renewalParamsReader;
        private readonly IEmailNotifier m_notifier;

        public AppSettingsRenewer(IRenewalManager renewalManager, IAppSettingsRenewalParamsReader renewalParamsReader, IEmailNotifier notifier)
        {
            m_renewalManager = renewalManager;
            m_renewalParamsReader = renewalParamsReader;
            m_notifier = notifier;
        }

        public void Renew()
        {
            var exceptions = new ConcurrentQueue<Exception>();
            Parallel.ForEach(m_renewalParamsReader.Read(), renewalParams =>
            {
                Events.RenewalInProgress(renewalParams);
                try
                {
                    m_renewalManager.Renew(renewalParams);
                    m_notifier.NotifyAsync(renewalParams).Wait(); // TODO use ForeachAsync when renewal manager supports it
                }
                catch (Exception e) when (!ExceptionHelper.IsCriticalException(e))
                {
                    Console.WriteLine("ERROR: Encountered exception: " + e);
                    exceptions.Enqueue(e);
                }
            });

            if (exceptions.Count > 0)
            {
                throw new AggregateException("Encountered exception(s) during cert renewal (and/or notification)", exceptions);
            }
        }
    }
}<commit_msg>Remove parallel renewal<commit_after>﻿using System;
using System.Collections.Concurrent;
using OhadSoft.AzureLetsEncrypt.Renewal.Management;
using OhadSoft.AzureLetsEncrypt.Renewal.WebJob.Email;
using OhadSoft.AzureLetsEncrypt.Renewal.WebJob.Telemetry;
using OhadSoft.AzureLetsEncrypt.Renewal.WebJob.Util;

namespace OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings
{
    internal class AppSettingsRenewer
    {
        private readonly IRenewalManager m_renewalManager;
        private readonly IAppSettingsRenewalParamsReader m_renewalParamsReader;
        private readonly IEmailNotifier m_notifier;

        public AppSettingsRenewer(IRenewalManager renewalManager, IAppSettingsRenewalParamsReader renewalParamsReader, IEmailNotifier notifier)
        {
            m_renewalManager = renewalManager;
            m_renewalParamsReader = renewalParamsReader;
            m_notifier = notifier;
        }

        public void Renew()
        {
            var exceptions = new ConcurrentQueue<Exception>();
            foreach (var renewalParams in m_renewalParamsReader.Read())
            {
                Events.RenewalInProgress(renewalParams);
                try
                {
                    m_renewalManager.Renew(renewalParams);
                    m_notifier.NotifyAsync(renewalParams).Wait(); // TODO use ForeachAsync when renewal manager supports it
                }
                catch (Exception e) when (!ExceptionHelper.IsCriticalException(e))
                {
                    Console.WriteLine("ERROR: Encountered exception: " + e);
                    exceptions.Enqueue(e);
                }
            }

            if (exceptions.Count > 0)
            {
                throw new AggregateException("Encountered exception(s) during cert renewal (and/or notification)", exceptions);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.06940736785904965, 'fraction_numerical': 0.0005339028296849973, 'mean_word_length': 2.3218085106382977, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '7065327', 'n_tokens_mistral': 1053, 'n_tokens_neox': 961, 'n_words': 179}