Default the throttle limit to 10 if not built with database support

This commit is contained in:
louiz’
2018-06-26 20:42:21 +02:00
parent 7f8a612c98
commit 0d886d5f32
2 changed files with 11 additions and 1 deletions
+10 -1
View File
@@ -144,7 +144,7 @@ IrcClient::IrcClient(std::shared_ptr<Poller>& poller, std::string hostname,
welcomed(false), welcomed(false),
chanmodes({"", "", "", ""}), chanmodes({"", "", "", ""}),
chantypes({'#', '&'}), chantypes({'#', '&'}),
tokens_bucket(Database::get_irc_server_options(bridge.get_bare_jid(), hostname).col<Database::ThrottleLimit>(), 1s, [this]() { tokens_bucket(this->get_throttle_limit(), 1s, [this]() {
if (message_queue.empty()) if (message_queue.empty())
return true; return true;
this->actual_send(std::move(this->message_queue.front())); this->actual_send(std::move(this->message_queue.front()));
@@ -1283,3 +1283,12 @@ bool IrcClient::abort_on_invalid_cert() const
return true; return true;
} }
#endif #endif
std::size_t IrcClient::get_throttle_limit() const
{
#ifdef USE_DATABASE
return Database::get_irc_server_options(this->bridge.get_bare_jid(), this->hostname).col<Database::ThrottleLimit>();
#else
return 10;
#endif
}
+1
View File
@@ -397,6 +397,7 @@ private:
*/ */
Resolver dns_resolver; Resolver dns_resolver;
TokensBucket tokens_bucket; TokensBucket tokens_bucket;
std::size_t get_throttle_limit() const;
}; };