using Microsoft.CodeAnalysis.CSharp.Syntax;
using Quadarax.Application.QLiberace.Common.Attributes;
using Quadarax.Application.QLiberace.Common.Settings;
using Quadarax.Application.QLiberace.Processor.Services;
using Quadarax.Application.QLiberace.Processor.Workers;
using Quadarax.Foundation.Core.Business.Interface;
namespace Quadarax.Application.QLiberace.Processor.Settings
{
[Module(Base.Constants.Modules.Processor.Code)]
public class ProcessorSetting : ModuleSetting
{
///
/// Defines number of working parallel
///
public int Workers { get; set; }
///
/// Defines number of working under one instance of
///
public int ProcessingThreadsPerWorker { get; set; }
///
/// Default processing worker PWI (Process Worker Identifier)
///
public string ProcessingWorkerPwi { get; set; } = null!;
///
/// Defines processing worker iteration interval (between two steps)
///
public TimeSpan ProcessingWorkerInterval { get; set; }
///
/// Defines processing worker iteration timeout (maximal iteration duration)
///
public TimeSpan ProcessingWorkerTimeout { get; set; }
///
/// Defines processing worker start delay two instances of worker (for fine tuning synchronization)
///
public TimeSpan ProcessingWorkerDelay { get; set; }
///
/// Defines number of working under one instance of
///
public int GarbageThreadsPerWorker { get; set; }
///
/// Default garbage worker PWI (Process Worker Identifier)
///
public string GarbageWorkerPwi { get; set; } = null!;
///
/// Defines garbage worker iteration interval (between two steps)
///
public TimeSpan GarbageWorkerInterval { get; set; }
///
/// Defines garbage worker iteration timeout (maximal iteration duration)
///
public TimeSpan GarbageWorkerTimeout { get; set; }
///
/// Defines garbage worker start delay two instances of worker (for fine tuning synchronization)
///
public TimeSpan GarbageWorkerDelay { get; set; }
///
/// Defines number of working under one instance of
///
public int RetentionThreadsPerWorker { get; set; }
///
/// Default retention worker PWI (Process Worker Identifier)
///
public string RetentionWorkerPwi { get; set; } = null!;
///
/// Defines retention worker iteration interval (between two steps)
///
public TimeSpan RetentionWorkerInterval { get; set; }
///
/// Defines retention worker iteration timeout (maximal iteration duration)
///
public TimeSpan RetentionWorkerTimeout { get; set; }
///
/// Defines retention worker start delay between two instances of worker (for fine tuning synchronization)
///
public TimeSpan RetentionWorkerDelay { get; set; }
#region *** Operations ***
public IWorkerSettings GetProcessingWorkerSettings()
{
return new WorkerSettings()
{
Interval = ProcessingWorkerInterval,
IterationTimeout = ProcessingWorkerTimeout,
StartDelay = ProcessingWorkerDelay,
WorkerCount = ProcessingThreadsPerWorker,
WorkerNamePrefix = ProcessingWorkerPwi
};
}
public IWorkerSettings GetGarbageWorkerSettings()
{
return new WorkerSettings()
{
Interval = GarbageWorkerInterval,
IterationTimeout = GarbageWorkerTimeout,
StartDelay = GarbageWorkerDelay,
WorkerCount = GarbageThreadsPerWorker,
WorkerNamePrefix = GarbageWorkerPwi
};
}
public IWorkerSettings GetRetentionWorkerSettings()
{
return new WorkerSettings()
{
Interval = RetentionWorkerInterval,
IterationTimeout = RetentionWorkerTimeout,
StartDelay = RetentionWorkerDelay,
WorkerCount = RetentionThreadsPerWorker,
WorkerNamePrefix = RetentionWorkerPwi
};
}
public override void SetDefaults()
{
Workers = Constants.Modules.Processor.ProcessorServiceCount;
ProcessingThreadsPerWorker = Constants.Modules.Processor.ProcessingThreads;
ProcessingWorkerPwi = Constants.Modules.Processor.PrefixProcessing;
ProcessingWorkerInterval = TimeSpan.Parse(Constants.Modules.Processor.ProcessingInterval);
ProcessingWorkerTimeout= TimeSpan.Parse(Constants.Modules.Processor.ProcessingTimeout);
ProcessingWorkerDelay = TimeSpan.Parse(Constants.Modules.Processor.ProcessingDelay);
GarbageThreadsPerWorker= Constants.Modules.Processor.GarbageThreads;
GarbageWorkerPwi = Constants.Modules.Processor.PrefixGarbage;
GarbageWorkerInterval= TimeSpan.Parse(Constants.Modules.Processor.GarbageInterval);
GarbageWorkerTimeout = TimeSpan.Parse(Constants.Modules.Processor.GarbageTimeout);
GarbageWorkerDelay= TimeSpan.Parse(Constants.Modules.Processor.GarbageDelay);
RetentionThreadsPerWorker = Constants.Modules.Processor.RetentionThreads;
RetentionWorkerPwi = Constants.Modules.Processor.PrefixRetention;
RetentionWorkerInterval = TimeSpan.Parse(Constants.Modules.Processor.RetentionInterval);
RetentionWorkerTimeout= TimeSpan.Parse(Constants.Modules.Processor.RetentionTimeout);
RetentionWorkerDelay= TimeSpan.Parse(Constants.Modules.Processor.RetentionDelay);
}
#endregion
#region *** Private operations ***
#endregion
#region *** Nested classes ***
#endregion
}
}