Esempio n. 1
0
        /// <inheritdoc/>
        public async Task <CommittedAggregateEvents> CommitForAggregate(UncommittedAggregateEvents uncommittedAggregateEvents, CancellationToken cancellationToken)
        {
            _logger.Debug("Committing events for aggregate");
            var request = new Contracts.CommitAggregateEventsRequest
            {
                CallContext = GetCurrentCallContext(),
                Events      = _eventConverter.ToProtobuf(uncommittedAggregateEvents),
            };
            var response = await _eventStoreClient.CommitForAggregateAsync(request, cancellationToken : cancellationToken);

            ThrowIfFailure(response.Failure);
            try
            {
                return(_eventConverter.ToSDK(response.Events));
            }
            catch (CouldNotDeserializeEvent ex)
            {
                throw new CouldNotDeserializeEventFromScope(ScopeId.Default, ex);
            }
        }