using Managing.Application.Abstractions.Services; using Microsoft.Extensions.Logging; using static Managing.Common.Enums; namespace Managing.Application.Workers; /// /// Represents a worker that watches traders and performs actions based on trading activities. /// Inherits from where TWorker is . /// public class TraderWatcher : BaseWorker { private readonly ITradingService _tradingService; private static readonly WorkerType _workerType = WorkerType.TraderWatcher; /// /// Initializes a new instance of the class. /// /// The logger to be used by the worker. /// The trading service to monitor trading activities. /// The worker service to manage worker lifecycle. public TraderWatcher( ILogger logger, IServiceProvider serviceProvider, ITradingService tradingService) : base( _workerType, logger, TimeSpan.FromSeconds(120), serviceProvider ) { _tradingService = tradingService; } /// /// Executes the worker's task to watch traders. This method is called periodically based on the worker's configured interval. /// /// A token to observe while waiting for the task to complete. protected override async Task Run(CancellationToken cancellationToken) { await _tradingService.WatchTrader(); } }