示例#1
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);
        }
示例#2
0
        public async Task <SagaConsumeContext <TSaga, TMessage> > Add(TSaga instance)
        {
            if (_sagasLocked)
            {
                var consumeContext = await _factory.CreateSagaConsumeContext(_sagas, _context, instance, SagaConsumeContextMode.Add).ConfigureAwait(false);

                _sagas.Release();
                _sagasLocked = false;

                return(consumeContext);
            }

            await _sagas.MarkInUse(_context.CancellationToken).ConfigureAwait(false);

            try
            {
                return(await _factory.CreateSagaConsumeContext(_sagas, _context, instance, SagaConsumeContextMode.Add).ConfigureAwait(false));
            }
            finally
            {
                _sagas.Release();
            }
        }