Ejemplo n.º 1
0
        public Task <T> Execute <T>(Func <SagaRepositoryContext <TSaga>, Task <T> > asyncMethod, CancellationToken cancellationToken)
            where T : class
        {
            var repositoryContext = new InMemorySagaRepositoryContext <TSaga>(_sagas, cancellationToken);

            return(asyncMethod(repositoryContext));
        }
Ejemplo n.º 2
0
        public async Task Send <T>(ConsumeContext <T> context, IPipe <SagaRepositoryContext <TSaga, T> > next)
            where T : class
        {
            await _sagas.MarkInUse(context.CancellationToken).ConfigureAwait(false);

            using var repositoryContext = new InMemorySagaRepositoryContext <TSaga, T>(_sagas, _factory, context);

            await next.Send(repositoryContext).ConfigureAwait(false);
        }
Ejemplo n.º 3
0
        public async Task SendQuery <T>(ConsumeContext <T> context, ISagaQuery <TSaga> query, IPipe <SagaRepositoryQueryContext <TSaga, T> > next)
            where T : class
        {
            await _sagas.MarkInUse(context.CancellationToken).ConfigureAwait(false);

            using var repositoryContext = new InMemorySagaRepositoryContext <TSaga, T>(_sagas, _factory, context);

            var matchingInstances = _sagas.Where(query).Select(x => x.Instance.CorrelationId).ToList();

            var queryContext = new DefaultSagaRepositoryQueryContext <TSaga, T>(repositoryContext, matchingInstances);

            await next.Send(queryContext).ConfigureAwait(false);
        }