Beispiel #1
0
 public SagaProducer(ISagaDescriptor descriptor, Func <object, TSaga> commonFactory) : this(descriptor)
 {
     foreach (var msgType in descriptor.StartMessages)
     {
         Register(msgType, commonFactory);
     }
 }
Beispiel #2
0
        public static CreateActorRouteMessage ForSaga(ISagaDescriptor descriptor, string name = null)
        {
            name = name ?? $"SagaHub_{descriptor.SagaType.BeautyName()}";

            var messageRoutes = descriptor.AcceptMessages
                                .Select(messageBinder => new MessageRoute(
                                            MessageMetadataEnvelop.GenericForType(messageBinder.MessageType),
                                            messageBinder.CorrelationField))
                                .ToArray();

            var hubType = typeof(SagaHubActor <,>).MakeGenericType(descriptor.SagaType,
                                                                   descriptor.StateType);

            return(new CreateActorRouteMessage(hubType, name, PoolKind.None, messageRoutes));
        }
Beispiel #3
0
        public static SagaConfiguration <ISagaInstance <TSaga, TData>, SagaDataAggregate <TData> > Instance <TSaga, TData, TFactory, TStartMessageA, TStartMessageB>
            (ISagaDescriptor descriptor, Func <ISnapshotsPersistencePolicy> snapShotsPolicy = null, Func <IMemento, SagaDataAggregate <TData> > stateConstructor = null)
            where TSaga : Saga <TData>
            where TData : class, ISagaState
            where TFactory : ISagaFactory <ISagaInstance <TSaga, TData>, SagaDataAggregate <TData> >,
        ISagaFactory <ISagaInstance <TSaga, TData>, TStartMessageA>,
        ISagaFactory <ISagaInstance <TSaga, TData>, TStartMessageB>,
        new()
        {
            var producer = new SagaProducer <ISagaInstance <TSaga, TData> >(descriptor);
            var factory  = new TFactory();

            producer.Register <TStartMessageA>(factory);
            producer.Register <TStartMessageB>(factory);
            producer.Register <SagaDataAggregate <TData> >(factory);
            stateConstructor = stateConstructor ?? SagaDataAggregate <TData> .FromSnapshot;

            return(new SagaConfiguration <ISagaInstance <TSaga, TData>, SagaDataAggregate <TData> >(producer, snapShotsPolicy, stateConstructor));
        }
Beispiel #4
0
        public void ExtractDescriptor()
        {
            var saga = new SoftwareProgrammingSaga();

            _descriptor = saga.CreateDescriptor <SoftwareProgrammingSaga, SoftwareProgrammingSagaData>(typeof(GotTiredEvent), typeof(SleptWellEvent));
        }
Beispiel #5
0
 public SagaProducer(ISagaDescriptor descriptor)
 {
     Descriptor = descriptor;
 }
Beispiel #6
0
        public static SagaConfiguration <TSaga, TState> State <TSaga, TState, TFactory, TStartMessage>(ISagaDescriptor descriptor,
                                                                                                       Func <ISnapshotsPersistencePolicy> snapShotsPolicy = null,
                                                                                                       Func <IMemento, TState> snapshotsConstructor       = null)
            where TFactory : ISagaFactory <TSaga, TState>,
        ISagaFactory <TSaga, TStartMessage>,
        new()

            where TSaga : class, ISagaInstance
            where TState : AggregateBase
        {
            var producer = new SagaProducer <TSaga>(descriptor);
            var factory  = new TFactory();

            producer.Register <TState>(factory);
            producer.Register <TStartMessage>(factory);

            return(new SagaConfiguration <TSaga, TState>(producer, snapShotsPolicy, snapshotsConstructor));
        }
Beispiel #7
0
        public static SagaConfiguration <ISagaInstance <TSaga, TData>, SagaDataAggregate <TData> > Instance <TSaga, TData>(Func <object, ISagaInstance <TSaga, TData> > factory, ISagaDescriptor descriptor, Func <ISnapshotsPersistencePolicy> snapShotsPolicy = null)
            where TSaga : Saga <TData>
            where TData : class, ISagaState
        {
            var producer = new SagaProducer <ISagaInstance <TSaga, TData> >(descriptor, factory);


            return(new SagaConfiguration <ISagaInstance <TSaga, TData>, SagaDataAggregate <TData> >(producer, snapShotsPolicy));
        }
Beispiel #8
0
 public static SagaConfiguration <ISagaInstance <TSaga, TData>, SagaDataAggregate <TData> > Instance <TSaga, TData, TFactory, TStartMessage>(ISagaDescriptor descriptor, Func <ISnapshotsPersistencePolicy> snapShotsPolicy = null)
     where TSaga : Saga <TData>
     where TData : class, ISagaState
     where TFactory : ISagaFactory <ISagaInstance <TSaga, TData>, SagaDataAggregate <TData> >,
 ISagaFactory <ISagaInstance <TSaga, TData>, TStartMessage>, new()
 {
     return(State <ISagaInstance <TSaga, TData>, SagaDataAggregate <TData>, TFactory, TStartMessage>(descriptor, snapShotsPolicy));
 }
        public static void RegisterStateSaga <TSaga, TState, TFactory, TStartMessage>(this IUnityContainer container, ISagaDescriptor descriptor)
            where TFactory : ISagaFactory <TSaga, TState>,
        ISagaFactory <TSaga, TStartMessage>,
        new()

            where TSaga : class, ISagaInstance
            where TState : AggregateBase
        {
            container.Register(SagaConfiguration.State <TSaga, TState, TFactory, TStartMessage>(descriptor));
        }
 public static void RegisterSaga <TSaga, TData>(this IUnityContainer container, Func <object, ISagaInstance <TSaga, TData> > factory, ISagaDescriptor descriptor, Func <ISnapshotsPersistencePolicy> snapShotsPolicy = null)
     where TSaga : Saga <TData>
     where TData : class, ISagaState
 {
     SagaConfiguration.Instance <TSaga, TData>(factory, descriptor)
     .Register(container);
 }
 public static void RegisterSaga <TSaga, TData, TFactory, TStartMessageA, TStartMessageB, TStartMessageC>(this IUnityContainer container, ISagaDescriptor descriptor)
     where TSaga : Saga <TData>
     where TData : class, ISagaState
     where TFactory : ISagaFactory <ISagaInstance <TSaga, TData>, SagaDataAggregate <TData> >,
 ISagaFactory <ISagaInstance <TSaga, TData>, TStartMessageA>,
 ISagaFactory <ISagaInstance <TSaga, TData>, TStartMessageB>,
 ISagaFactory <ISagaInstance <TSaga, TData>, TStartMessageC>,
 new()
 {
     SagaConfiguration.Instance <TSaga, TData, TFactory, TStartMessageA, TStartMessageB, TStartMessageC>(descriptor)
     .Register(container);
 }
 public Task RegisterSaga(ISagaDescriptor sagaDescriptor, string name)
 {
     var createActorRoute = CreateActorRouteMessage.ForSaga(sagaDescriptor, name);
     return _routingActor.Ask<RouteCreated>(createActorRoute);
 }