Exemplo n.º 1
0
        public async Task Should_get_app_with_schema_from_index()
        {
            var schema = Mocks.Schema(app.NamedId(), schemaId);

            A.CallTo(() => indexForApps.GetAppAsync(app.Id, false, ct))
            .Returns(app);

            A.CallTo(() => indexForSchemas.GetSchemaAsync(app.Id, schema.Id, false, ct))
            .Returns(schema);

            var result = await sut.GetAppWithSchemaAsync(app.Id, schemaId.Id, false, ct);

            Assert.Equal(schema, result.Item2);
        }
Exemplo n.º 2
0
        public async Task UpdateAsync()
        {
            var ids = await indexForApps.GetIdsAsync();

            foreach (var id in ids)
            {
                var app = await indexForApps.GetAppAsync(id);

                if (app != null && app.Patterns.Count == 0)
                {
                    foreach (var pattern in initialPatterns.Values)
                    {
                        var command =
                            new AddPattern
                        {
                            Actor     = app.CreatedBy,
                            AppId     = id,
                            Name      = pattern.Name,
                            PatternId = Guid.NewGuid(),
                            Pattern   = pattern.Pattern,
                            Message   = pattern.Message
                        };

                        await commandBus.PublishAsync(command);
                    }
                }
            }
        }
Exemplo n.º 3
0
 public Task <IAppEntity?> GetAppAsync(DomainId appId)
 {
     return(localCache.GetOrCreateAsync($"GetAppAsync({appId})", async() =>
     {
         return await indexForApps.GetAppAsync(appId);
     }));
 }
Exemplo n.º 4
0
        public async Task <IAppEntity?> GetAppAsync(DomainId appId, bool canCache = false,
                                                    CancellationToken ct          = default)
        {
            var cacheKey = AppCacheKey(appId);

            var app = await GetOrCreate(cacheKey, () =>
            {
                return(indexForApps.GetAppAsync(appId, canCache, ct));
            });

            if (app != null)
            {
                localCache.Add(AppCacheKey(app.Name), app);
            }

            return(app);
        }
Exemplo n.º 5
0
        public async Task <IAppEntity?> GetAppAsync(DomainId appId, bool canCache = false,
                                                    CancellationToken ct          = default)
        {
            var cacheKey = AppCacheKey(appId);

            if (localCache.TryGetValue(cacheKey, out var cached) && cached is IAppEntity found)
            {
                return(found);
            }

            var app = await indexForApps.GetAppAsync(appId, canCache, ct);

            if (app != null)
            {
                localCache.Add(cacheKey, app);
                localCache.Add(AppCacheKey(app.Name), app);
            }

            return(app);
        }
Exemplo n.º 6
0
        public async Task <IAppEntity?> GetAppAsync(DomainId appId, bool canCache = false)
        {
            var app = await localCache.GetOrCreateAsync(AppCacheKey(appId), () =>
            {
                return(indexForApps.GetAppAsync(appId, canCache));
            });

            if (app != null)
            {
                localCache.Add(AppCacheKey(app.Id), app);
            }

            return(app?.IsArchived == true ? null : app);
        }