From 97b0eb447e36308cd6783add28de88e429627bfe Mon Sep 17 00:00:00 2001 From: Dmitry Mikushin Date: Sun, 12 Feb 2023 22:38:29 +0100 Subject: Parameterizing the number of retries and backoff duration for HttpClient.makeRequest --- include/tgbot/net/HttpClient.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/tgbot/net/HttpClient.h b/include/tgbot/net/HttpClient.h index 024c8ad..90b93dd 100644 --- a/include/tgbot/net/HttpClient.h +++ b/include/tgbot/net/HttpClient.h @@ -28,6 +28,18 @@ public: virtual std::string makeRequest(const Url& url, const std::vector& args) const = 0; std::int32_t _timeout = 25; + + virtual int getRequestMaxRetries() const { + return requestMaxRetries; + } + + virtual int getRequestBackoff() const { + return requestBackoff; + } + +private: + int requestMaxRetries = 3; + int requestBackoff = 1; }; } -- cgit v1.2.3 From 69e2faa1828eb9c73b592faa69a64ea6c98ec6cf Mon Sep 17 00:00:00 2001 From: Dmitry Mikushin Date: Sun, 12 Feb 2023 22:42:03 +0100 Subject: Adding briefs for the new functions --- include/tgbot/net/HttpClient.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/tgbot/net/HttpClient.h b/include/tgbot/net/HttpClient.h index 90b93dd..9b93328 100644 --- a/include/tgbot/net/HttpClient.h +++ b/include/tgbot/net/HttpClient.h @@ -29,10 +29,16 @@ public: std::int32_t _timeout = 25; + /** + * @brief Get the maximum number of makeRequest() retries before giving up and throwing an exception. + */ virtual int getRequestMaxRetries() const { return requestMaxRetries; } + /** + * @brief Get the makeRequest() backoff duration between retries, in seconds. + */ virtual int getRequestBackoff() const { return requestBackoff; } -- cgit v1.2.3