Skip to content

Commit

Permalink
Merge pull request #10 from pinkenburg/100sec-retry
Browse files Browse the repository at this point in the history
change retry mechanics
  • Loading branch information
ligerlac authored Jan 22, 2024
2 parents 76e8c34 + de1876a commit d4290d3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/realwrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <nopayloadclient/realwrapper.hpp>

#include <cstdlib>

namespace nopayloadclient {

RealWrapper::RealWrapper(const json& config) {
Expand All @@ -10,7 +12,8 @@ RealWrapper::RealWrapper(const json& config) {
}

void RealWrapper::sleep(int retry_number) {
int n_sleep = int(std::exp(retry_number));
srand(time(0));
int n_sleep = rand()%100+1; // add random sleep 1-100 secs
logging::debug("sleeping for " + std::to_string(n_sleep) + " seconds before retrying...");
std::this_thread::sleep_for(std::chrono::seconds(n_sleep));
}
Expand Down Expand Up @@ -69,4 +72,4 @@ json CurlRequest::parseResponse() {
return response;
}

}
}

0 comments on commit d4290d3

Please sign in to comment.