Browse Source

Another version fix.

pull/680/head
Sebastian Stehle 5 years ago
parent
commit
e46da8f51f
  1. 5
      backend/src/Squidex.Infrastructure/Commands/DomainObject.cs
  2. 2
      backend/src/Squidex.Infrastructure/States/BatchPersistence.cs
  3. 2
      backend/src/Squidex.Infrastructure/States/IPersistence.cs
  4. 5
      backend/src/Squidex.Infrastructure/States/Persistence.cs

5
backend/src/Squidex.Infrastructure/Commands/DomainObject.cs

@ -312,6 +312,11 @@ namespace Squidex.Infrastructure.Commands
if (persistence != null) if (persistence != null)
{ {
await persistence.ReadAsync(); await persistence.ReadAsync();
if (persistence.IsSnapshotStale)
{
await persistence.WriteSnapshotAsync(Snapshot);
}
} }
} }

2
backend/src/Squidex.Infrastructure/States/BatchPersistence.cs

@ -21,6 +21,8 @@ namespace Squidex.Infrastructure.States
public long Version { get; } public long Version { get; }
public bool IsSnapshotStale => false;
internal BatchPersistence(DomainId ownerKey, BatchContext<T> context, long version, IReadOnlyList<Envelope<IEvent>> @events, internal BatchPersistence(DomainId ownerKey, BatchContext<T> context, long version, IReadOnlyList<Envelope<IEvent>> @events,
HandleEvent? applyEvent) HandleEvent? applyEvent)
{ {

2
backend/src/Squidex.Infrastructure/States/IPersistence.cs

@ -15,6 +15,8 @@ namespace Squidex.Infrastructure.States
{ {
long Version { get; } long Version { get; }
bool IsSnapshotStale { get; }
Task DeleteAsync(); Task DeleteAsync();
Task WriteEventsAsync(IReadOnlyList<Envelope<IEvent>> events); Task WriteEventsAsync(IReadOnlyList<Envelope<IEvent>> events);

5
backend/src/Squidex.Infrastructure/States/Persistence.cs

@ -44,6 +44,11 @@ namespace Squidex.Infrastructure.States
get => (persistenceMode & PersistenceMode.EventSourcing) == PersistenceMode.EventSourcing; get => (persistenceMode & PersistenceMode.EventSourcing) == PersistenceMode.EventSourcing;
} }
public bool IsSnapshotStale
{
get => persistenceMode == PersistenceMode.SnapshotsAndEventSourcing && versionSnapshot < versionEvents;
}
public Persistence(DomainId ownerKey, Type ownerType, public Persistence(DomainId ownerKey, Type ownerType,
ISnapshotStore<T> snapshotStore, ISnapshotStore<T> snapshotStore,
IEventStore eventStore, IEventStore eventStore,

Loading…
Cancel
Save