/
vshmidt
/
masstransit
Обзор
Документация
Войти
/
vshmidt
/
masstransit
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/MassTransit/Configuration/SagaStateMachineReceiveEndpointExtensions.cs
47 строк
2 KB
Chris Patterson
Huge push towards optimization on startup, state machines, type discovery, caching, and the consume pipeline. Rebuilt the dispatch filter as a consume context filter for message type dispatch.
27 мар 2024, 02:43
27 мар 2024, 02:43
c17b1de
Код
Авторство
О чём код?
#nullable enable namespace MassTransit { using System; using Configuration; public static class SagaStateMachineReceiveEndpointExtensions { /// <summary> /// Subscribe a state machine saga to the endpoint /// </summary> /// <typeparam name="TInstance">The state machine instance type</typeparam> /// <param name="configurator"></param> /// <param name="stateMachine">The state machine</param> /// <param name="repository">The saga repository for the instances</param> /// <param name="configure">Optionally configure the saga</param> /// <returns></returns> public static void StateMachineSaga<TInstance>(this IReceiveEndpointConfigurator configurator, SagaStateMachine<TInstance> stateMachine, ISagaRepository<TInstance> repository, Action<ISagaConfigurator<TInstance>>? configure = null) where TInstance : class, SagaStateMachineInstance { if (stateMachine == null) throw new ArgumentNullException(nameof(stateMachine)); if (repository == null) throw new ArgumentNullException(nameof(repository)); var stateMachineConfigurator = new MassTransitStateMachine<TInstance>.StateMachineSagaConfigurator(stateMachine, repository, configurator); configure?.Invoke(stateMachineConfigurator); configurator.AddEndpointSpecification(stateMachineConfigurator); } public static ConnectHandle ConnectStateMachineSaga<TInstance>(this IConsumePipeConnector bus, SagaStateMachine<TInstance> stateMachine, ISagaRepository<TInstance> repository, Action<ISagaConfigurator<TInstance>>? configure = null) where TInstance : class, SagaStateMachineInstance { var connector = new MassTransitStateMachine<TInstance>.StateMachineConnector(stateMachine); ISagaSpecification<TInstance> specification = connector.CreateSagaSpecification<TInstance>(); configure?.Invoke(specification); return connector.ConnectSaga(bus, repository, specification); } } }