using Microsoft.Extensions.Hosting;

namespace ScadaLink.SiteRuntime.Persistence;

/// <summary>
/// Hosted service that initializes the SQLite schema on startup.
/// Runs before the Akka actor system starts creating actors.
/// </summary>
public class SiteStorageInitializer : IHostedService
{
    private readonly SiteStorageService _storage;

    public SiteStorageInitializer(SiteStorageService storage)
    {
        _storage = storage;
    }

    public async Task StartAsync(CancellationToken cancellationToken)
    {
        await _storage.InitializeAsync();
    }

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