Exemplo n.º 1
0
        async Task <IProcessingResult> Process(CommittedEvent @event, CancellationToken cancellationToken)
        {
            _logger.Trace(
                "Processing Event {EventType} from Event Horizon in Scope {Scope} from Microservice {ProducerMicroservice} and Tenant {ProducerTenant}",
                @event.Type.Id,
                Scope,
                _subscriptionId.ProducerMicroserviceId,
                _subscriptionId.ProducerTenantId);

            await _policy.Execute(
                cancellationToken => _receivedEventsWriter.Write(@event, _consentId, Scope, cancellationToken),
                cancellationToken).ConfigureAwait(false);

            return(new SuccessfulProcessing());
        }
Exemplo n.º 2
0
    /// <inheritdoc />
    public async Task Commit(CommittedEvents events, ConsentId consent, ScopeId scope)
    {
        foreach (var @event in events)
        {
            var sequenceNumber = await _policies.WriteEvent.ExecuteAsync(
                _ => _receivedEventsWriter.Write(@event, consent, scope, CancellationToken.None),
                CancellationToken.None).ConfigureAwait(false);

            await _eventStoreClient.CommitExternal(new CommitExternalEventsRequest
            {
                ScopeId = scope.ToProtobuf(),
                Event   = new CommittedEvent(
                    sequenceNumber,
                    @event.Occurred,
                    @event.EventSource,
                    @event.ExecutionContext,
                    @event.Type,
                    @event.Public,
                    @event.Content).ToProtobuf()
            }, CancellationToken.None).ConfigureAwait(false);
        }
    }