-
Notifications
You must be signed in to change notification settings - Fork 233
Expand file tree
/
Copy pathccapi_http_retry.h
More file actions
30 lines (24 loc) · 860 Bytes
/
ccapi_http_retry.h
File metadata and controls
30 lines (24 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once
#include <future>
#include <string>
namespace ccapi {
/**
* This class is used for retrying http requests for the REST API.
*/
class HttpRetry {
public:
explicit HttpRetry(int numRetry = 0, int numRedirect = 0, std::string redirectUrlStr = "",
std::shared_ptr<std::promise<void>> promisePtr = std::shared_ptr<std::promise<void>>(nullptr))
: numRetry(numRetry), numRedirect(numRedirect), promisePtr(promisePtr) {}
std::string toString() const {
std::ostringstream oss;
oss << promisePtr;
std::string output =
"HttpRetry [numRetry = " + ccapi::toString(numRetry) + ", numRedirect = " + ccapi::toString(numRedirect) + ", promisePtr = " + oss.str() + "]";
return output;
}
int numRetry;
int numRedirect;
std::shared_ptr<std::promise<void>> promisePtr;
};
} /* namespace ccapi */