public async Task <TSideEffect> Once <TSideEffect>(Func <TState, TSideEffect> action)
        {
            var maxDelay = TimeSpan.FromSeconds(20);
            var delay    = TimeSpan.FromMilliseconds(500);

            do
            {
                try
                {
                    var operationId = $"{typeof(TState).Name}-{stateId}-{requestId}";

                    return(await processor.Process(operationId, stateId, action));
                }
                catch (OptimisticConcurrencyFailure)
                {
                    await Task.Delay(delay);

                    delay *= 2;
                }
            } while (delay <= maxDelay);

            throw new OptimisticConcurrencyFailure();
        }
Пример #2
0
 public Task <TSideEffect> WithOutput <TSideEffect>(Func <TState, TSideEffect> action)
 {
     return(processor.Process <TState, TSideEffect>(requestId, stateId, action));
 }