예제 #1
0
        /// <inheritdoc/>
        public async Task <CommittedEvents> Commit(UncommittedEvents uncommittedEvents, CancellationToken cancellationToken)
        {
            _logger.Debug("Committing events");
            var request = new Contracts.CommitEventsRequest
            {
                CallContext = GetCurrentCallContext(),
            };

            request.Events.AddRange(_eventConverter.ToProtobuf(uncommittedEvents));
            var response = await _eventStoreClient.CommitAsync(request, cancellationToken : cancellationToken);

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