Exemplo n.º 1
0
        public async Task Should_call_snapshot_store_on_clear()
        {
            await sut.ClearSnapshotsAsync <string, int>();

            A.CallTo(() => snapshotStore.ClearAsync())
            .MustHaveHappened();
        }
Exemplo n.º 2
0
        public async Task RebuildConfigAsync()
        {
            await snapshotAppStore.ClearAsync();

            await snapshotRuleStore.ClearAsync();

            await snapshotSchemaStore.ClearAsync();

            const string filter = "^((app\\-)|(schema\\-)|(rule\\-))";

            var handledIds = new HashSet <Guid>();

            await eventStore.QueryAsync(async storedEvent =>
            {
                var @event = ParseKnownEvent(storedEvent);

                if (@event != null)
                {
                    if (@event.Payload is SchemaEvent schemaEvent && handledIds.Add(schemaEvent.SchemaId.Id))
                    {
                        var schema = await stateFactory.GetSingleAsync <SchemaGrain>(schemaEvent.SchemaId.Id);

                        await schema.WriteSnapshotAsync();
                    }
                    else if (@event.Payload is RuleEvent ruleEvent && handledIds.Add(ruleEvent.RuleId))
                    {
                        var rule = await stateFactory.GetSingleAsync <RuleGrain>(ruleEvent.RuleId);

                        await rule.WriteSnapshotAsync();
                    }
Exemplo n.º 3
0
        public async Task RebuildAssetsAsync()
        {
            await snapshotAssetStore.ClearAsync();

            const string filter = "^asset\\-";

            var handledIds = new HashSet <Guid>();

            await eventStore.QueryAsync(async storedEvent =>
            {
                var @event = ParseKnownEvent(storedEvent);

                if (@event != null)
                {
                    if (@event.Payload is AssetEvent assetEvent && handledIds.Add(assetEvent.AssetId))
                    {
                        var asset = await stateFactory.CreateAsync <AssetGrain>(assetEvent.AssetId);

                        asset.ApplySnapshot(asset.Snapshot.Apply(@event));

                        await asset.WriteSnapshotAsync();
                    }
                }
            }, filter, ct : CancellationToken.None);
        }
Exemplo n.º 4
0
        public async Task Should_call_snapshot_store_on_clear()
        {
            await sut.ClearSnapshotsAsync();

            A.CallTo(() => snapshotStore.ClearAsync(A <CancellationToken> ._))
            .MustHaveHappened();
        }
Exemplo n.º 5
0
 public Task ClearSnapshotsAsync()
 {
     return(snapshotStore.ClearAsync());
 }