public static Func <Func <IReliableStateManager, ITransaction, IEvent, Task>, CancellationToken, Task> Reader(this IReliableStateManager stateManager, Func <EventData, IEvent> deserializer, string mailBoxName) => async(f, token) => { await stateManager.UseTransactionAsync(tx => stateManager.DequeueAsync( tx, e => f(stateManager, tx, e), deserializer, token, queueName: mailBoxName) ); };
public static Task DequeueAsync <T>(this IReliableStateManager stateManager, Func <T, Task> action, Func <EventData, T> deserializer, CancellationToken cancellationToken, string queueName = defaultOutBoxQueueName) => stateManager.UseTransactionAsync(tx => stateManager.DequeueAsync(tx, action, deserializer, cancellationToken, true, queueName), autoCommit: false);
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));
//TODO move to queue etx public static Task EnqueuAsync(this IReliableStateManager stateManager, IEvent @event, Func <IEvent, EventData> serialzer, string queueName) => stateManager.UseTransactionAsync(tx => stateManager.EnqueuAsync(tx, new[] { @event }, serialzer, queueName));