using Managing.Application.Abstractions.Services;
using Managing.Application.Workers;
using Managing.Application.Workers.Abstractions;
using static Managing.Common.Enums;
namespace Managing.Api.Workers.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,
ITradingService tradingService,
IWorkerService workerService) : base(
_workerType,
logger,
TimeSpan.FromSeconds(120),
workerService
)
{
_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();
}
}