Example #1
0
        public async Task Set(ArticlePayload articlePayload, CancellationToken token = default)
        {
            articlePayload.VerifyNotNull(nameof(articlePayload));

            _logger.LogTrace($"{nameof(Set)}: Writing {articlePayload.Id}");
            await _dataLakeStore.Write(ToFullFileName(articlePayload.Id), articlePayload.ToBytes(), true, token);
        }
Example #2
0
        public ArticleCache(ArticlePayload articlePayload)
        {
            articlePayload.VerifyNotNull(nameof(articlePayload));
            articlePayload.Verify();

            ArticlePayload = articlePayload;
        }
Example #3
0
        public async Task Set(ArticlePayload articlePayload, CancellationToken token = default)
        {
            articlePayload.VerifyNotNull(nameof(articlePayload));

            _logger.LogTrace($"{nameof(Set)}: Id={articlePayload.Id}");

            await _httpClient.PostAsJsonAsync("api/article", articlePayload, token);
        }
Example #4
0
        public async Task Set(ArticlePayload articlePayload, CancellationToken token)
        {
            articlePayload.VerifyNotNull(nameof(articlePayload))
            .VerifyAssert(x => articlePayload.Id.ToLower() == base.ActorKey.Value, $"Id mismatch - id={articlePayload.Id.ToLower()}, actorKey={base.ActorKey}");

            _logger.LogTrace($"{nameof(Set)}: Writing {articlePayload.Id}");
            await _acticleStore.Set(articlePayload, token);

            _cache.Set(articlePayload);
        }
        public async Task Set(ArticlePayload record, CancellationToken token = default)
        {
            record.VerifyNotNull(nameof(record));

            var actorKey = new ActorKey(new ArticleId(record.Id).ToString());

            _logger.LogTrace($"{nameof(Set)}: actorKey={actorKey}, id={record.Id}");

            IArticlePackageActor actor = _actorHost !.GetActor <IArticlePackageActor>(actorKey);
            await actor.Set(record, token);
        }
        public static void Verify(this ArticlePayload subject)
        {
            subject.VerifyNotNull(nameof(subject));

            subject.Id.VerifyNotEmpty(nameof(subject.Id));
            subject.PackagePayload.VerifyAssert(x => x?.Length > 0, $"{nameof(subject.PackagePayload)} is required");
            subject.Hash.VerifyNotEmpty($"{nameof(subject.Hash)} is required");

            byte[] packagePayload = Convert.FromBase64String(subject.PackagePayload);
            byte[] hash           = MD5.Create().ComputeHash(packagePayload);

            Convert.ToBase64String(hash).VerifyAssert(x => x == subject.Hash, "Hash verification failed");
        }