Browse Source

Use index for event store.

pull/516/head
Sebastian 6 years ago
parent
commit
ca32acc0b4
  1. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/DefaultAppImageStore.cs
  2. 2
      backend/src/Squidex.Domain.Apps.Entities/Backup/DefaultBackupArchiveStore.cs
  3. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/ScriptContent.cs
  4. 34
      backend/src/Squidex.Domain.Apps.Entities/EventStoreInitializer.cs
  5. 2
      backend/src/Squidex.Domain.Apps.Entities/Rules/Runner/GrainRuleRunnerService.cs
  6. 4
      backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Reader.cs
  7. 2
      backend/src/Squidex.Infrastructure/IInitializable.cs
  8. 4
      backend/src/Squidex/Config/Domain/BackupsServices.cs
  9. 2
      backend/src/Squidex/Config/Startup/InitializerHost.cs

2
backend/src/Squidex.Domain.Apps.Entities/Apps/DefaultAppImageStore.cs

@ -20,7 +20,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
public DefaultAppImageStore(IAssetStore assetStore)
{
Guard.NotNull(assetStore, nameof(assetStore));
Guard.NotNull(assetStore);
this.assetStore = assetStore;
}

2
backend/src/Squidex.Domain.Apps.Entities/Backup/DefaultBackupArchiveStore.cs

@ -20,7 +20,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
public DefaultBackupArchiveStore(IAssetStore assetStore)
{
Guard.NotNull(assetStore, nameof(assetStore));
Guard.NotNull(assetStore);
this.assetStore = assetStore;
}

2
backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/ScriptContent.cs

@ -19,7 +19,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries.Steps
public ScriptContent(IScriptEngine scriptEngine)
{
Guard.NotNull(scriptEngine, nameof(scriptEngine));
Guard.NotNull(scriptEngine);
this.scriptEngine = scriptEngine;
}

34
backend/src/Squidex.Domain.Apps.Entities/EventStoreInitializer.cs

@ -0,0 +1,34 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Threading;
using System.Threading.Tasks;
using Squidex.Domain.Apps.Events;
using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
namespace Squidex.Domain.Apps.Entities
{
public sealed class EventStoreInitializer : IInitializable
{
private readonly IEventStore eventStore;
public int Order => 1000;
public EventStoreInitializer(IEventStore eventStore)
{
Guard.NotNull(eventStore);
this.eventStore = eventStore;
}
public Task InitializeAsync(CancellationToken ct = default)
{
return eventStore.CreateIndexAsync(SquidexHeaders.AppId);
}
}
}

2
backend/src/Squidex.Domain.Apps.Entities/Rules/Runner/GrainRuleRunnerService.cs

@ -18,7 +18,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.Runner
public GrainRuleRunnerService(IGrainFactory grainFactory)
{
Guard.NotNull(grainFactory, nameof(grainFactory));
Guard.NotNull(grainFactory);
this.grainFactory = grainFactory;
}

4
backend/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore_Reader.cs

@ -30,7 +30,9 @@ namespace Squidex.Infrastructure.EventSourcing
return Collection.Indexes.CreateOneAsync(
new CreateIndexModel<MongoEventCommit>(
Index.Ascending(CreateIndexPath(property))));
Index
.Ascending(CreateIndexPath(property))
.Ascending(TimestampField)));
}
public IEventSubscription CreateSubscription(IEventSubscriber subscriber, string? streamFilter = null, string? position = null)

2
backend/src/Squidex.Infrastructure/IInitializable.cs

@ -12,6 +12,8 @@ namespace Squidex.Infrastructure
{
public interface IInitializable
{
int Order => 0;
Task InitializeAsync(CancellationToken ct = default);
}
}

4
backend/src/Squidex/Config/Domain/BackupsServices.cs

@ -6,6 +6,7 @@
// ==========================================================================
using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Entities;
using Squidex.Domain.Apps.Entities.Apps;
using Squidex.Domain.Apps.Entities.Assets;
using Squidex.Domain.Apps.Entities.Backup;
@ -42,6 +43,9 @@ namespace Squidex.Config.Domain
services.AddTransientAs<BackupSchemas>()
.As<IBackupHandler>();
services.AddSingletonAs<EventStoreInitializer>()
.AsSelf();
}
}
}

2
backend/src/Squidex/Config/Startup/InitializerHost.cs

@ -26,7 +26,7 @@ namespace Squidex.Config.Startup
protected override async Task StartAsync(ISemanticLog log, CancellationToken ct)
{
foreach (var target in targets.Distinct())
foreach (var target in targets.Distinct().OrderBy(x => x.Order))
{
await target.InitializeAsync(ct);

Loading…
Cancel
Save