using Microsoft.Extensions.Hosting; namespace ZB.MOM.WW.ScadaBridge.SiteRuntime.Persistence; /// /// Hosted service that initializes the SQLite schema on startup. /// Runs before the Akka actor system starts creating actors. /// public class SiteStorageInitializer : IHostedService { private readonly SiteStorageService _storage; /// /// Initializes a new . /// /// The site storage service whose schema is initialized on startup. public SiteStorageInitializer(SiteStorageService storage) { _storage = storage; } /// /// Initializes the SQLite schema before the actor system starts. /// /// Cancellation token for the startup operation. /// A task that represents the asynchronous operation. public async Task StartAsync(CancellationToken cancellationToken) { await _storage.InitializeAsync(); } /// /// No-op stop; schema initialization does not require cleanup. /// /// Unused cancellation token. /// A task that represents the asynchronous operation. public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; }