public async Task <FetchForAggregateResponse> FetchForAggregate(FetchForAggregateRequest request) { var result = await _eventStore.FetchAggregateEvents(request, HttpContext.RequestAborted).ConfigureAwait(false); if (result.Failure is not null) { Response.StatusCode = StatusCodes.Status500InternalServerError; } return(result); }
/// <inheritdoc /> public async Task <FetchForAggregateResponse> FetchAggregateEvents(FetchForAggregateRequest request, CancellationToken cancellationToken) { try { var events = await _getCommittedEventsFetcher(GetTenantFrom(request.CallContext)) .FetchForAggregate(request.Aggregate.EventSourceId, request.Aggregate.AggregateRootId.ToGuid(), cancellationToken); return(new FetchForAggregateResponse { Events = events.ToProtobuf() }); } catch (Exception e) { _logger.ErrorFetchingEventsFromAggregate(e); return(new FetchForAggregateResponse { Failure = e.ToFailure() }); } }
/// <inheritdoc/> public override Task <FetchForAggregateResponse> FetchForAggregate(FetchForAggregateRequest request, ServerCallContext context) => _eventStore.FetchAggregateEvents(request, context.CancellationToken);