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);
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); } }
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);
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));
public static Task EnqueuAsync(this IReliableStateManager stateManager, ITransaction tx, IEvent @event, Func <IEvent, EventData> serializer, string queueName) => stateManager.EnqueuAsync(tx, new[] { @event }, serializer, queueName);
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
public static Func <ITransaction, IEvent[], Task> WriterWithTransaction(this IReliableStateManager stateManager, Func <IEvent, EventData> serializer, string mailBoxName) => (tx, events) => stateManager.EnqueuAsync(tx, events, serializer, mailBoxName);