Codefactor review
This commit is contained in:
@@ -31,7 +31,6 @@ namespace Scrobbling
|
||||
class Scrobbling : public IScrobbling
|
||||
{
|
||||
public:
|
||||
|
||||
Scrobbling(Database::Db& db);
|
||||
|
||||
private:
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace Scrobbling
|
||||
InternalScrobbler(Database::Db& db);
|
||||
|
||||
private:
|
||||
|
||||
void listenStarted(const Listen& listen) override;
|
||||
void listenFinished(const Listen& listen, std::chrono::seconds duration) override;
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace Scrobbling
|
||||
LOG(DEBUG) << "POST done. status = " << msg.status() << ", msg = '" << msg.body() << "'";
|
||||
if (ec)
|
||||
{
|
||||
LOG(ERROR) << "Client error: " << ec.message();
|
||||
LOG(ERROR) << "Retry " << queuedListen.retryCount << ", client error: '" << ec.message() << "'";
|
||||
// may be a network error, try again later
|
||||
if (++queuedListen.retryCount > _maxRetryCount)
|
||||
_sendQueue.pop_front();
|
||||
@@ -363,7 +363,7 @@ namespace Scrobbling
|
||||
{
|
||||
assert(_state == State::Idle);
|
||||
|
||||
const std::chrono::seconds duration {requestedDuration.count() > 0 ? requestedDuration : std::chrono::seconds {1}};
|
||||
const std::chrono::seconds duration {clamp(requestedDuration, _minRetryWaitDuration, _maxRetryWaitDuration)};
|
||||
LOG(DEBUG) << "Throttling for " << duration.count() << " seconds";
|
||||
|
||||
_ioService.schedule(duration, [this]
|
||||
|
||||
@@ -74,6 +74,8 @@ namespace Scrobbling
|
||||
const std::string _apiEndpoint;
|
||||
const std::size_t _maxRetryCount {2};
|
||||
const std::chrono::seconds _defaultRetryWaitDuration {30};
|
||||
const std::chrono::seconds _minRetryWaitDuration {1};
|
||||
const std::chrono::seconds _maxRetryWaitDuration {300};
|
||||
|
||||
Database::Db& _db;
|
||||
Wt::WIOService _ioService;
|
||||
|
||||
Reference in New Issue
Block a user