|
|
|
@ -9,25 +9,31 @@ using System.Collections.Generic; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Orleans.Runtime; |
|
|
|
using Squidex.Infrastructure.Log; |
|
|
|
|
|
|
|
namespace Squidex.Infrastructure.Orleans |
|
|
|
{ |
|
|
|
public sealed class InitializerStartup : IStartupTask |
|
|
|
{ |
|
|
|
private readonly IEnumerable<IInitializable> initializables; |
|
|
|
private readonly IEnumerable<IInitializable> targets; |
|
|
|
private readonly ISemanticLog log; |
|
|
|
|
|
|
|
public InitializerStartup(IEnumerable<IInitializable> initializables) |
|
|
|
public InitializerStartup(IEnumerable<IInitializable> targets, ISemanticLog log) |
|
|
|
{ |
|
|
|
Guard.NotNull(initializables, nameof(initializables)); |
|
|
|
Guard.NotNull(targets, nameof(targets)); |
|
|
|
|
|
|
|
this.initializables = initializables; |
|
|
|
this.targets = targets; |
|
|
|
|
|
|
|
this.log = log; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task Execute(CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
foreach (var initializable in initializables) |
|
|
|
foreach (var target in targets) |
|
|
|
{ |
|
|
|
await initializable.InitializeAsync(cancellationToken); |
|
|
|
await target.InitializeAsync(cancellationToken); |
|
|
|
|
|
|
|
log?.LogInformation(w => w.WriteProperty("siloInitializedSystem", target.GetType().Name)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|