/// <inheritdoc/> protected override async Task <EventHandlerResponse> Handle(HandleEventRequest request, CancellationToken cancellationToken) { try { var committed = _converter.ToSDK(request.Event.Event); try { if (committed.Event is TEventType typedEvent) { await _handler.Handle(typedEvent, committed.DeriveContext()).ConfigureAwait(false); return(new EventHandlerResponse()); } throw new EventHandlerDoesNotHandleEvent(typeof(TEventType)); } finally { try { var correlationId = committed.ExecutionContext.CorrelationId; var eventType = committed.Event.GetType(); _completion.EventHandlerCompletedForEvent(correlationId, Identifier, eventType); } catch (Exception ex) { _logger.Warning(ex, "Error notifying waiters of event handler completion"); } } } catch (CouldNotDeserializeEvent ex) { throw new CouldNotDeserializeEventFromScope(request.Event.ScopeId.To <ScopeId>(), ex); } }
async Task <IProcessingResult> Process(HandleEventRequest request, ExecutionContext executionContext, CancellationToken cancellationToken) { var response = await _dispatcher.Call(request, executionContext, cancellationToken).ConfigureAwait(false); return(response switch { { Failure : null } => new SuccessfulProcessing(),
/// <inheritdoc /> public Task <IProcessingResult> Process(CommittedEvent @event, PartitionId partitionId, ExecutionContext executionContext, CancellationToken cancellationToken) { _logger.EventProcessorIsProcessing(Identifier, @event.Type.Id, partitionId); var request = new HandleEventRequest { Event = new Contracts.StreamEvent { Event = @event.ToProtobuf(), PartitionId = partitionId.Value, ScopeId = Scope.ToProtobuf() }, }; return(Process(request, executionContext, cancellationToken)); }
/// <inheritdoc/> public Task <IProcessingResult> Process(CommittedEvent @event, PartitionId partitionId, string failureReason, uint retryCount, ExecutionContext executionContext, CancellationToken cancellationToken) { _logger.EventProcessorIsProcessingAgain(Identifier, @event.Type.Id, partitionId, retryCount, failureReason); var request = new HandleEventRequest { Event = new Contracts.StreamEvent { Event = @event.ToProtobuf(), PartitionId = partitionId.Value, ScopeId = Scope.ToProtobuf() }, RetryProcessingState = new RetryProcessingState { FailureReason = failureReason, RetryCount = retryCount } }; return(Process(request, executionContext, cancellationToken)); }
/// <inheritdoc /> public Task <IProcessingResult> Process(CommittedEvent @event, PartitionId partitionId, CancellationToken cancellationToken) { _logger.Debug( "{LogMessagePrefix} is processing event '{EventTypeId}' for partition '{PartitionId}'", _logMessagePrefix, @event.Type.Id.Value, partitionId.Value); var request = new HandleEventRequest { Event = new Contracts.StreamEvent { Event = @event.ToProtobuf(), PartitionId = partitionId.ToProtobuf(), ScopeId = Scope.ToProtobuf() }, }; return(Process(request, cancellationToken)); }
/// <inheritdoc/> public Task <IProcessingResult> Process(CommittedEvent @event, PartitionId partitionId, string failureReason, uint retryCount, CancellationToken cancellationToken) { _logger.Debug( "{LogMessagePrefix} is processing event '{EventTypeId}' for partition '{PartitionId}' again for the {RetryCount}. time because: {FailureReason}", _logMessagePrefix, @event.Type.Id.Value, partitionId.Value, retryCount, failureReason); var request = new HandleEventRequest { Event = new Contracts.StreamEvent { Event = @event.ToProtobuf(), PartitionId = partitionId.ToProtobuf(), ScopeId = Scope.ToProtobuf() }, RetryProcessingState = new RetryProcessingState { FailureReason = failureReason, RetryCount = retryCount } }; return(Process(request, cancellationToken)); }
/// <inheritdoc/> protected override RetryProcessingState GetRetryProcessingState(HandleEventRequest request) => request.RetryProcessingState;