public Task <T> Execute <T>(Func <SagaRepositoryContext <TSaga>, Task <T> > asyncMethod, CancellationToken cancellationToken = default) where T : class { var repositoryContext = new CosmosSagaRepositoryContext <TSaga>(_context, cancellationToken); return(asyncMethod(repositoryContext)); }
public Task Send <T>(ConsumeContext <T> context, IPipe <SagaRepositoryContext <TSaga, T> > next) where T : class { var repositoryContext = new CosmosSagaRepositoryContext <TSaga, T>(_context, context, _factory); return(next.Send(repositoryContext)); }
public async Task SendQuery <T>(ConsumeContext <T> context, ISagaQuery <TSaga> query, IPipe <SagaRepositoryQueryContext <TSaga, T> > next) where T : class { IEnumerable <TSaga> sagas = await _context.Container.GetItemLinqQueryable <TSaga>() .Where(query.FilterExpression) .QueryAsync(context.CancellationToken) .ConfigureAwait(false); var repositoryContext = new CosmosSagaRepositoryContext <TSaga, T>(_context, context, _factory); var queryContext = new DefaultSagaRepositoryQueryContext <TSaga, T>(repositoryContext, sagas.Select(x => x.CorrelationId).ToList()); await next.Send(queryContext).ConfigureAwait(false); }