using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;

namespace StellaOps.Vexer.Storage.Mongo.Migrations;

internal sealed class VexMongoMigrationHostedService : IHostedService
{
    private readonly VexMongoMigrationRunner _runner;

    public VexMongoMigrationHostedService(VexMongoMigrationRunner runner)
    {
        _runner = runner ?? throw new ArgumentNullException(nameof(runner));
    }

    public async Task StartAsync(CancellationToken cancellationToken)
    {
        await _runner.RunAsync(cancellationToken).ConfigureAwait(false);
    }

    public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
}
