<commit_before>﻿using Acquaintance.PubSub;
using System;

namespace Acquaintance.Timers
{
    public static class TimerMessageBusExtensions
    {
        public static IDisposable TimerSubscribe(this IPubSubBus messageBus, int multiple, Action<IActionSubscriptionBuilder<MessageTimerEvent>> build)
        {
            if (messageBus == null)
                throw new ArgumentNullException(nameof(messageBus));
            if (multiple <= 0)
                throw new ArgumentOutOfRangeException(nameof(multiple));
            if (build == null)
                throw new ArgumentNullException(nameof(build));

            return messageBus.Subscribe<MessageTimerEvent>(builder =>
            {
                var b2 = builder.WithTopic(MessageTimerEvent.EventName);
                build(b2);
                var b3 = b2 as IDetailsSubscriptionBuilder<MessageTimerEvent>;
                b3.WithFilter(t => t.Id % multiple == 0);
            });
        }

        public static IDisposable EnableMessageTimer(this IMessageBus messageBus, string name = null, int delayMs = 5000, int intervalMs = 10000)
        {
            if (messageBus == null)
                throw new ArgumentNullException(nameof(messageBus));

            return messageBus.Modules.Add(new MessageTimer(name, delayMs, intervalMs));
        }
    }
}<commit_msg>Timer extensions cleanups<commit_after>﻿using Acquaintance.PubSub;
using System;
using Acquaintance.Utility;

namespace Acquaintance.Timers
{
    public static class TimerMessageBusExtensions
    {
        public static IDisposable TimerSubscribe(this IPubSubBus messageBus, int multiple, Action<IActionSubscriptionBuilder<MessageTimerEvent>> build)
        {
            Assert.ArgumentNotNull(messageBus, nameof(messageBus));
            Assert.IsInRange(multiple, nameof(multiple), 1, int.MaxValue);
            Assert.ArgumentNotNull(build, nameof(build));

            return messageBus.Subscribe<MessageTimerEvent>(builder =>
            {
                var b2 = builder.WithTopic(MessageTimerEvent.EventName);
                build(b2);
                var b3 = b2 as IDetailsSubscriptionBuilder<MessageTimerEvent>;
                b3.WithFilter(t => t.Id % multiple == 0);
            });
        }

        public static IDisposable EnableMessageTimer(this IMessageBus messageBus, string name = null, int delayMs = 5000, int intervalMs = 10000)
        {
            Assert.ArgumentNotNull(messageBus, nameof(messageBus));

            return messageBus.Modules.Add(new MessageTimer(name, delayMs, intervalMs));
        }
    }
}
{'fraction_non_alphanumeric': 0.08410852713178295, 'fraction_numerical': 0.012403100775193798, 'mean_word_length': 2.56, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 15, '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': '6952966', 'n_tokens_mistral': 695, 'n_tokens_neox': 648, 'n_words': 148}