2020-08-09 02:26:41 +02:00
|
|
|
|
namespace Giants.Services
|
2020-08-09 01:31:16 +02:00
|
|
|
|
{
|
2020-08-09 02:26:41 +02:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
|
2020-08-09 02:52:26 +02:00
|
|
|
|
public class InitializerService : IHostedService
|
2020-08-09 01:31:16 +02:00
|
|
|
|
{
|
2022-09-05 22:42:41 +02:00
|
|
|
|
private readonly IVersioningStore updaterStore;
|
2020-08-09 01:31:16 +02:00
|
|
|
|
private readonly IServerRegistryStore serverRegistryStore;
|
|
|
|
|
|
2020-08-10 09:22:33 +02:00
|
|
|
|
public InitializerService(
|
2022-09-05 22:42:41 +02:00
|
|
|
|
IVersioningStore updaterStore,
|
2020-08-10 09:22:33 +02:00
|
|
|
|
IServerRegistryStore serverRegistryStore)
|
2020-08-09 01:31:16 +02:00
|
|
|
|
{
|
2020-08-10 09:22:33 +02:00
|
|
|
|
// TODO: Pick these up from reflection and auto initialize
|
|
|
|
|
this.updaterStore = updaterStore;
|
2020-08-09 01:31:16 +02:00
|
|
|
|
this.serverRegistryStore = serverRegistryStore;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task StartAsync(CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
await this.serverRegistryStore.Initialize();
|
2020-08-10 09:22:33 +02:00
|
|
|
|
await this.updaterStore.Initialize();
|
2020-08-09 01:31:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task StopAsync(CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|