namespace GeoRitmMover.Services;
public class MovingBackgroundService(
	IServiceProvider serviceProvider,
	IHostApplicationLifetime hostApplicationLifetime
) : BackgroundService
{

	private readonly ILogger<MovingBackgroundService> _logger = serviceProvider
		.CreateScope().ServiceProvider.GetRequiredService<ILogger<MovingBackgroundService>>();
	private readonly ITableMoverFactory _tableMoverFactory = serviceProvider
		.CreateScope().ServiceProvider.GetRequiredService<ITableMoverFactory>();

	protected override async Task ExecuteAsync(CancellationToken stoppingToken)
	{
		_logger.LogInformation("Starting moving");

		var movers = _tableMoverFactory.CreateTableMovers();
		foreach (var mover in movers)
		{
			await mover.Move(stoppingToken);
		}

		_logger.LogInformation("Done moving");

		hostApplicationLifetime.StopApplication();
	}
}
