// 1. If all servers are healthy, then the first server should be selected.
// 1. If all servers are healthy, then the first server should be selected.
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: First server should be selected"<<std::endl;
// 2. Failed servers should be retried after the retry delay.
// 2. Failed servers should be retried after the retry delay.
//
//
// Fail server #0 but leave server #1 as healthy.
// Fail server #0 but leave server #1 as healthy.
tv_now=std::chrono::high_resolution_clock::now();
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Server0 will fail but leave Server1 as healthy"<<std::endl;
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Server0 should be past retry delay and should be tried again successfully"<<std::endl;
// Fail all servers for the first round of tries. On the second round server
// Fail all servers for the first round of tries. On the second round server
// #1 responds successfully.
// #1 responds successfully.
tv_now=std::chrono::high_resolution_clock::now();
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: All 3 servers will fail on the first attempt. On second attempt, Server0 will fail, but Server1 will answer correctly."<<std::endl;
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Past retry delay, so will choose Server2 and Server0 that are down. Server2 will fail but Server0 will succeed."<<std::endl;
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Retry delay has not been hit yet. Server0 was last successful, so should be tried first (and will fail), Server1 is also healthy so will respond."<<std::endl;
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Retry delay has expired on Server2 but not Server0, will try on Server2 and fail, then Server1 will answer"<<std::endl;
// 1. If all servers are healthy, then the first server should be selected.
// 1. If all servers are healthy, then the first server should be selected.
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: First server should be selected"<<std::endl;
// 2. Failed servers should be retried after the retry delay.
// 2. Failed servers should be retried after the retry delay.
//
//
// Fail server #0 but leave server #1 as healthy.
// Fail server #0 but leave server #1 as healthy.
tv_now=std::chrono::high_resolution_clock::now();
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Server0 will fail but leave Server1 as healthy"<<std::endl;
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Server0 should be past retry delay and should be tried again successfully"<<std::endl;
// Fail all servers for the first round of tries. On the second round server
// Fail all servers for the first round of tries. On the second round server
// #1 responds successfully.
// #1 responds successfully.
tv_now=std::chrono::high_resolution_clock::now();
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: All 3 servers will fail on the first attempt. On second attempt, Server0 will fail, but Server1 will answer correctly."<<std::endl;
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Past retry delay, so will choose Server2 and Server0 that are down. Server2 will fail but Server0 will succeed."<<std::endl;
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Retry delay has not been hit yet. Server0 was last successful, so should be tried first (and will fail), Server1 is also healthy so will respond."<<std::endl;
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Retry delay has expired on Server2 but not Server0, will try on Server2 and fail, then Server1 will answer"<<std::endl;
// 1. If all servers are healthy, then the first server should be selected.
// 1. If all servers are healthy, then the first server should be selected.
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: First server should be selected"<<std::endl;
// 2. Failed servers should be retried after the retry delay.
// 2. Failed servers should be retried after the retry delay.
//
//
// Fail server #0 but leave server #1 as healthy.
// Fail server #0 but leave server #1 as healthy.
tv_now=std::chrono::high_resolution_clock::now();
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Server0 will fail but leave Server1 as healthy"<<std::endl;
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Server0 should be past retry delay and should be tried again successfully"<<std::endl;
// Fail all servers for the first round of tries. On the second round server
// Fail all servers for the first round of tries. On the second round server
// #1 responds successfully.
// #1 responds successfully.
tv_now=std::chrono::high_resolution_clock::now();
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: All 3 servers will fail on the first attempt. On second attempt, Server0 will fail, but Server1 will answer correctly."<<std::endl;
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Past retry delay, so will choose Server2 and Server0 that are down. Server2 will fail but Server0 will succeed."<<std::endl;
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Retry delay has not been hit yet. Server0 was last successful, so should be tried first (and will fail), Server1 is also healthy so will respond."<<std::endl;
if(verbose)std::cerr<<std::chrono::duration_cast<std::chrono::milliseconds>(tv_now-tv_begin).count()<<"ms: Retry delay has expired on Server2 but not Server0, will try on Server2 and fail, then Server1 will answer"<<std::endl;