using Quadarax.Foundation.Core.Logging; namespace Quadarax.Foundation.Core.Business.Processor.Queue; public class ProcessQueueConfiguration { #region *** Properties *** public int WorkersCount {get; private set;} //number of max processing workers public TimeSpan WatchdogInterval {get; private set;} //Interval to watchdog monitor and emits new worker public TimeSpan RetentionInterval {get; private set;} //retention - Interval to run retention mechanism. If set to TimeSpan.Zero, retention disabled. public TimeSpan RetentionClearOlderThan {get; private set;} //retention - clear all status Deleted older than value in all queue types public TimeSpan RetentionDeletedOlderThan {get; private set;} //retention - mark all items to status Deleted older than value in Succ, Fail queue #endregion #region *** Private Fields *** private ILog _log; #endregion public ProcessQueueConfiguration(int workersCount, TimeSpan watchdogInterval) { WorkersCount = workersCount; WatchdogInterval = watchdogInterval; _log = new ConsoleLogger().GetLogger(GetType()); } public void Validate() { var errors = new List(); if (WorkersCount==0) errors.Add(new ArgumentOutOfRangeException(nameof(WorkersCount), "WorkersCount must be bigger than zero.")); if (WatchdogInterval == TimeSpan.Zero) errors.Add(new ArgumentOutOfRangeException(nameof(WatchdogInterval), "WatchdogInterval must be bigger than TimeSpan.Zero.")); if (errors.Count>0) throw new AggregateException("ProcessQueue configuration has some invalid values.", errors); _log.Log(LogSeverityEnum.Debug, "Configuration validated."); } }