예제 #1
0
    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);
    }
예제 #2
0
    /// <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()
            });
        }
    }
예제 #3
0
 /// <inheritdoc/>
 public override Task <FetchForAggregateResponse> FetchForAggregate(FetchForAggregateRequest request, ServerCallContext context)
 => _eventStore.FetchAggregateEvents(request, context.CancellationToken);