public override async Task <string> RunResultAsRawJson(ReqlAst term, object globalOpts, CancellationToken cancelToken) { HostEntry host = GetRoundRobin(); try { return(await host.conn.RunResultAsRawJson(term, globalOpts, cancelToken).ConfigureAwait(false)); } catch (Exception e) when(ExceptionIs.NetworkError(e)) { host.MarkFailed(); throw; } }
public override void RunNoReply(ReqlAst term, object globalOpts) { HostEntry host = GetRoundRobin(); try { host.conn.RunNoReply(term, globalOpts); } catch (Exception e) when(ExceptionIs.NetworkError(e)) { host.MarkFailed(); throw; } }
public override void RunNoReply(ReqlAst term, object globalOpts) { HostEntry host = GetEpsilonGreedy(); try { var start = DateTime.Now.Ticks; host.conn.RunNoReply(term, globalOpts); var end = DateTime.Now.Ticks; MarkSuccess(host, start, end); } catch (Exception e) when(ExceptionIs.NetworkError(e)) { host.MarkFailed(); throw; } }
public override async Task <Cursor <T> > RunCursorAsync <T>(ReqlAst term, object globalOpts, CancellationToken cancelToken) { HostEntry host = GetEpsilonGreedy(); try { var start = DateTime.Now.Ticks; var result = await host.conn.RunCursorAsync <T>(term, globalOpts, cancelToken).ConfigureAwait(false); var end = DateTime.Now.Ticks; MarkSuccess(host, start, end); return(result); } catch (Exception e) when(ExceptionIs.NetworkError(e)) { host.MarkFailed(); throw; } }
public void failure_should_double_retry() { var he = new HostEntry("a") { RetryDelayMax = TimeSpan.FromSeconds(300), RetryDelayInitial = TimeSpan.FromSeconds(30) }; he.MarkFailed(); he.Dead.Should().BeTrue(); he.RetryCount.Should().Be(0); he.NextRetry.Should().BeCloseTo(DateTime.Now.AddSeconds(30), precision: 3000); he.RetryFailed(); he.RetryCount.Should().Be(1); he.NextRetry.Should().BeCloseTo(DateTime.Now.AddSeconds(30 * 2), precision: 3000); he.RetryFailed(); he.RetryCount.Should().Be(2); he.NextRetry.Should().BeCloseTo(DateTime.Now.AddSeconds(30 * 2 * 2), precision: 3000); //run it past the maximum Enumerable.Range(1, 30 * 12) .ForEach(i => he.RetryFailed()); he.RetryFailed(); he.NextRetry.Should().BeCloseTo(DateTime.Now + he.RetryDelayMax, precision: 1000); }