async Task <PipeResult <R> > IAsyncExecutor <M, R> .ExecuteAsync( M model, IPipeCache pipeCache) { Cache = pipeCache; return(await RunAsync(model)); }
public static T GetSafely <T>(this IPipeCache cache, object key) { if (cache != null && key != null) { return(cache.Get <T>(key)); } return(default);
public async Task <PipeResult <int> > ExecuteAsync( IntModel model, IPipeCache pipeCache = null) { model.Integer += 100; return(await Task.FromResult(PipeResult <int> .DefaultSuccessful .SetValue(model.Integer))); }
public async Task <PipeResult <R> > RunAsync(M model, IPipeCache cache) { if (_executorInstance == null) { _executorInstance = _executor(); } return(await _executorInstance.ExecuteAsync(model, cache)); }
public async Task <PipeResult <double> > ExecuteAsync( IntModel model, IPipeCache pipeCache = null) { await Task.Delay(50); return(PipeResult <double> .DefaultSuccessful .SetValue(50)); }
public async Task <PipeResult <TimeSpan> > ExecuteAsync( IntModel model, IPipeCache pipeCache = null) { await Task.Delay(100); return(PipeResult <TimeSpan> .DefaultSuccessful .SetValue(TimeSpan.FromMilliseconds(100))); }
public async Task <PipeResult <R> > RunAsync(M model, IPipeCache cache) { var stopWatch = new Stopwatch(); stopWatch.Start(); var result = await _container.RunAsync(model, cache); stopWatch.Stop(); result.SetElapsed(stopWatch.Elapsed); return(result); }
public async Task <PipeResult <R> > RunAsync(M model, IPipeCache cache) { var result = await _container.RunAsync(model, cache); if (result.Success == ExecutionResult.Failed && _count > 0) { return(await ReTryAsync(model, cache)); } return(result); }
public async Task <PipeResult <int> > ExecuteAsync( IntModel model, IPipeCache pipeCache = null) { _restrictionTester.IncrementCounter(); await Task.Delay(100); model.Integer += 3; pipeCache.SetSafely <int>("3", model.Integer); _restrictionTester.DecrementCounter(); return(PipeResult <int> .DefaultSuccessful .SetValue(model.Integer)); }
public async Task <PipeResult <int> > ExecuteAsync( IntModel model, IPipeCache pipeCache = null) { var x1 = pipeCache.GetSafely <int>("1"); var x2 = pipeCache.GetSafely <int>("2"); var x3 = pipeCache.GetSafely <int>("3"); var x4 = pipeCache.GetSafely <int>("4"); model.Integer += x1 + x2 + x3 + x4; return(await Task.FromResult(PipeResult <int> .DefaultSuccessful .SetValue(model.Integer))); }
private async Task <PipeResult <R> > ReTryAsync(M model, IPipeCache cache) { for (int i = 0; i < _count - 1; i++) { var result = await _container.RunAsync(model, cache); if (result.Success == ExecutionResult.Successful) { return(result); } await Task.Delay(_timeOutMilliseconds); } return(await _container.RunAsync(model, cache)); }
public async Task <PipeResult <R> > RunAsync(M model, IPipeCache cache) { var result = PipeResult <R> .Default; if (_semaphore == null) { return(await _container.RunAsync(model, cache)); } await _semaphore.WaitAsync(); try { result = await _container.RunAsync(model, cache); } finally { _semaphore.Release(); } return(result); }
public async Task <PipeResult <R> > RunAsync(M model, IPipeCache cache) { var result = (await _executor(model, cache)); return(result);//.SetLabel(_label); }