internal T Send <T>(IOrientDBOperation <T> operation) { Exception _lastException = null; var i = maxAttempts; while (i-- > 0) { try { var stream = GetNetworkStream(); T result = Process(operation, stream); ReturnStream(stream); return(result); } catch (IOException ex) { if (_lastException == null) { _lastException = ex; } else { _lastException = new Exception("Retry patern exception", ex); } } } throw _lastException; }
internal T Send <T>(IOrientDBOperation <T> operation) { Exception lastException = null; var i = maxAttempts; while (i-- > 0) { try { var stream = GetNetworkStream(); T result = Process(operation, stream); ReturnStream(stream); return(result); } catch (IOException ex) { lastException = lastException == null ? ex : new Exception("Retry patern exception", ex); } } throw lastException ?? throw new Exception("Retry patern exception"); }
private async Task <T> ProcessAsync <T>(IOrientDBOperation <T> operation, OrientDBNetworkConnection stream) { try { var request = operation.CreateRequest(stream.SessionId, stream.Token); var reader = await SendAsync(request, stream.GetStream()); return(operation.Execute(reader)); } catch { Destroy(stream); throw; } }
internal async Task <T> SendAsync <T>(IOrientDBOperation <T> operation) { var policy = Policy .Handle <IOException>() .WaitAndRetryAsync( maxAttempts, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)) ); return(await policy.ExecuteAsync(async() => { var stream = GetNetworkStream(); var result = await ProcessAsync(operation, stream); ReturnStream(stream); return result; })); }
private T Process <T>(IOrientDBOperation <T> operation, OrientDBNetworkConnection stream) { try { Request request = operation.CreateRequest(stream.SessionId, stream.Token); var reader = Send(request, stream.GetStream()); T result = operation.Execute(reader); return(result); } catch { Destroy(stream); throw; } }