<commit_before>﻿namespace King.Service.Data
{
    using King.Azure.Data;
    using King.Service.Data.Model;
    using King.Service.Scalability;
    using King.Service.Timing;
    using System.Collections.Generic;

    /// <summary>
    /// Storage Queue AutoScaler
    /// </summary>
    /// <typeparam name="T">Processor Type</typeparam>
    public class StorageQueueAutoScaler<T> : QueueAutoScaler<IQueueSetup>
    {
        #region Constructors
        /// <summary>
        /// Default Constructor
        /// </summary>
        /// <param name="count">Count</param>
        /// <param name="messagesPerScaleUnit">Messages Per-Scale Unit</param>
        /// <param name="setup">Setup</param>
        /// <param name="minimum">Minimum Scale</param>
        /// <param name="maximum">Maximmum Scale</param>
        /// <param name="checkScaleInMinutes">Check Scale Every</param>
        public StorageQueueAutoScaler(IQueueCount count, IQueueSetup setup, ushort messagesPerScaleUnit = QueueScaler<T>.MessagesPerScaleUnitDefault, byte minimum = 1, byte maximum = 2, byte checkScaleInMinutes = BaseTimes.ScaleCheck)
            : base(count, messagesPerScaleUnit, setup, minimum, maximum, checkScaleInMinutes)
        {
        }
        #endregion

        #region Methods
        /// <summary>
        /// Scale Unit
        /// </summary>
        /// <param name="setup">Setup</param>
        /// <returns>Scalable Task</returns>
        public override IEnumerable<IScalable> ScaleUnit(IQueueSetup setup)
        {
            var processor = setup.Get<T>();
            var dequeue = new StorageDequeueBatchDynamic<T>(setup.Name, setup.ConnectionString, processor);
            switch (setup.Priority)
            {
                case QueuePriority.High:
                case QueuePriority.Medium:
                    yield return new BackoffRunner(dequeue);
                    break;
                default:
                    yield return new AdaptiveRunner(dequeue);
                    break;
            }
        }
        #endregion
    }
}<commit_msg>Set Dequeue Timing Ranges<commit_after>﻿namespace King.Service.Data
{
    using King.Azure.Data;
    using King.Service.Data.Model;
    using King.Service.Scalability;
    using King.Service.Timing;
    using System.Collections.Generic;

    /// <summary>
    /// Storage Queue AutoScaler
    /// </summary>
    /// <typeparam name="T">Processor Type</typeparam>
    public class StorageQueueAutoScaler<T> : QueueAutoScaler<IQueueSetup>
    {
        #region Constructors
        /// <summary>
        /// Default Constructor
        /// </summary>
        /// <param name="count">Count</param>
        /// <param name="messagesPerScaleUnit">Messages Per-Scale Unit</param>
        /// <param name="setup">Setup</param>
        /// <param name="minimum">Minimum Scale</param>
        /// <param name="maximum">Maximmum Scale</param>
        /// <param name="checkScaleInMinutes">Check Scale Every</param>
        public StorageQueueAutoScaler(IQueueCount count, IQueueSetup setup, ushort messagesPerScaleUnit = QueueScaler<T>.MessagesPerScaleUnitDefault, byte minimum = 1, byte maximum = 2, byte checkScaleInMinutes = BaseTimes.ScaleCheck)
            : base(count, messagesPerScaleUnit, setup, minimum, maximum, checkScaleInMinutes)
        {
        }
        #endregion

        #region Methods
        /// <summary>
        /// Scale Unit
        /// </summary>
        /// <param name="setup">Setup</param>
        /// <returns>Scalable Task</returns>
        public override IEnumerable<IScalable> ScaleUnit(IQueueSetup setup)
        {
            var processor = setup.Get<T>();
            var minimumPeriodInSeconds = BaseTimes.MinimumStorageTiming;
            var maximumPeriodInSeconds = BaseTimes.MaximumStorageTiming;
            switch (setup.Priority)
            {
                case QueuePriority.High:
                    minimumPeriodInSeconds = 1;
                    maximumPeriodInSeconds = BaseTimes.MinimumStorageTiming;
                    break;
                case QueuePriority.Medium:
                    minimumPeriodInSeconds /= 2;
                    maximumPeriodInSeconds /= 2;
                    break;
            }

            var dequeue = new StorageDequeueBatchDynamic<T>(setup.Name, setup.ConnectionString, processor, minimumPeriodInSeconds, maximumPeriodInSeconds);

            switch (setup.Priority)
            {
                case QueuePriority.High:
                    yield return new BackoffRunner(dequeue, Strategy.Linear);
                    break;
                case QueuePriority.Medium:
                    yield return new BackoffRunner(dequeue, Strategy.Exponential);
                    break;
                default:
                    yield return new AdaptiveRunner(dequeue);
                    break;
            }
        }
        #endregion
    }
}
{'fraction_non_alphanumeric': 0.10575745202123316, 'fraction_numerical': 0.0014291547570436914, 'mean_word_length': 1.9423423423423423, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, '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': '3389422', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1222, 'n_words': 262}