diff --git a/CHANGELOG.md b/CHANGELOG.md index db775cd..4fc0a5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Unreleased +- Async API requests. - One more description for StaleChat error. # 0.8.0 diff --git a/README.md b/README.md index 277e9e2..baea89e 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,8 @@ Package contains: - Middleware and routes helpers for production env. - Poller with automatic source-reloader for development env. - Rake tasks to update webhook urls. -- Async requests for Telegram and/or Botan API. Let the queue adapter handle errors! +- __[Async mode](#async-mode)__ for Telegram and/or Botan API. + Let the queue adapter handle network errors! Here is sample [telegram_bot_app](https://github.com/telegram-bot-rb/telegram_bot_app) with session, keyboards and inline queries. @@ -384,11 +385,24 @@ you can implement your own worker class to handle such requests. This allows: - Handle and retry network and other errors with queue adapter. - ??? +Instead of performing request instantly client serializes it, pushes to queue, +and immediately return control back. The job is then fetched with a worker +and real API request is performed. And this all is absolutely transparent for the app. + To enable this mode add `async: true` to bot's and botan's config. For more information and custom configuration check out [docs](http://www.rubydoc.info/github/telegram-bot-rb/telegram-bot/master/Telegram/Bot/Async) or [source](https://github.com/telegram-bot-rb/telegram-bot/blob/master/lib/telegram/bot/async.rb). +Be aware of some limitations: + +- Client will not return API response. +- Sending files is not available in async mode [now], + because them can not be serialized. + +To disable async mode for the block of code use `bot.async(false) { bot.send_photo }`. +Yes, it's threadsafe too. + ## Development After checking out the repo, run `bin/setup` to install dependencies.