TeleDart
TeleDart copied to clipboard
Implement FIFO queue in http client
Is your feature request related to a problem?
Users have reported 429 errors happening frequently in roughly the same time frame(#226), root causes is still unknown but it's clear that teledart client is making too many requests and it's exceeding telegram bot api's burst-able rate (See https://core.telegram.org/bots/faq#my-bot-is-hitting-limits-how-do-i-avoid-this).
Describe the solution you'd like
Implement a FIFO queue and a rate limited consumer in http_client.dart
. Each http request error need to be categorised as retry-able and not retry-able, see https://github.com/TelegramBotAPI/errors. The rate limiter and request queue needs to be global, http_client.dart
needs to become a singleton as part of the solution. Some of the hacky retry logic can be taken out from long_polling.dart