예제 #1
0
 public static OrderModule Initialize(IReliableStateManager stateManager, Func <IEvent[], Task> eventLogger)
 => Initialize(stateManager, tx => new ReliableEventStore(
                   stateManager,
                   tx,
                   Serialization.Json(),
                   Serialization.JsonDeserialization(TypeResolver.FromMap(TypeResolver.GetEventsFromTypes(typeof(ItemAddedEvent))))       //TODO "share" with publisher
                   ),
               (tx, events) => stateManager.EnqueuAsync(tx, events, Serialization.Json()),
               eventLogger);
예제 #2
0
        public static async Task <long> AppendToStreamAsync(this IReliableStateManager stateManager,
                                                            string streamName, long version, IEvent[] events, Func <IEvent, EventData> serializer,
                                                            string queueName = defaultOutBoxQueueName, string streamsName = defaultStreamsName)
        {
            using (var tx = stateManager.CreateTransaction())
            {
                var result = await stateManager.AppendAndMapToStreamAsync(tx, streamName, version, events, serializer, streamsName);

                await stateManager.EnqueuAsync(tx, result.Item1.Select(x => x.ToEventData()), queueName);

                await tx.CommitAsync();

                return(result.Item2);
            }
        }
예제 #3
0
 public static Task EnqueuAsync <T>(this IReliableStateManager stateManager, ITransaction tx, IEnumerable <T> events, Func <T, EventData> serializer, string queueName = defaultOutBoxQueueName)
     where T : IEvent
 => stateManager.EnqueuAsync(tx, events.Select(x => serializer(x)), queueName);
예제 #4
0
 public static Task EnqueuAsync <T>(this IReliableStateManager stateManager, IEnumerable <T> events, Func <T, EventData> serialzer, string queueName = defaultOutBoxQueueName)
     where T : IEvent
 => stateManager.UseTransactionAsync(tx => stateManager.EnqueuAsync(tx, events, serialzer, queueName));
예제 #5
0
 public static Task EnqueuAsync(this IReliableStateManager stateManager, ITransaction tx, IEvent @event, Func <IEvent, EventData> serializer, string queueName)
 => stateManager.EnqueuAsync(tx, new[] { @event }, serializer, queueName);
예제 #6
0
파일: Mailbox.cs 프로젝트: crapitan/Fiffi
 public static Func <IEvent, CancellationToken, Task> Writer(this IReliableStateManager sm, Func <IEvent, EventData> serializer, string mailBoxName)
 => (e, ct) => sm.EnqueuAsync(new IEvent[] { e }, serializer, mailBoxName);         //TODO ct
예제 #7
0
파일: Mailbox.cs 프로젝트: crapitan/Fiffi
 public static Func <ITransaction, IEvent[], Task> WriterWithTransaction(this IReliableStateManager stateManager, Func <IEvent, EventData> serializer, string mailBoxName)
 => (tx, events) => stateManager.EnqueuAsync(tx, events, serializer, mailBoxName);