Improve UpdateManager flexibility #68
Replies: 1 comment 4 replies
-
|
Well, I've finished the splitting. :) I've successfully divided the I’ve pushed a commit to a forked repository to give you access to assess the changes I’ve made so far... If this is of interest to you, of course. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I’ve been working on implementing webhooks for a few days. As far as I know, the library currently doesn’t provide built-in support for working with webhooks directly. To address this, I’ve been using another open-source library that provides an HTTP server. With this setup, I can now deserialize webhook data into an
RxTelegram.Bot.Interface.Setup.Updateobject, which is already part of this library. I noticed that the internal processes of theUpdateManagerclass utilizeUpdateobjects as well, processing them through theDistributeUpdatesmethod. I would like to have the ability to processUpdateobjects received externally in the same way, by passing them throughDistributeUpdates.This method appears to be flexible enough to handle updates from any provider, whether it’s long-polling, webhooks, or other custom sources. This observation led me to consider potential improvements to the
UpdateManagerdesign. Right now, theUpdateManager.RunUpdatemethod acts as a standalone service, specifically designed for long-polling requests.To make the system more modular and extensible, I propose splitting the
UpdateManagerinto two separate components:UpdateDistributorandIUpdateTracker.UpdateDistributorwould handle the distribution of rawUpdateobjects from theIUpdateTracker.IUpdateTrackerwould be responsible for tracking and retrieving updates, allowing for multiple implementations. [edited: I just finished draft version of Webhook tracker and it looks more natural to useIObservable<Update>for tracker]By default, the
UpdateManagercould use a long-polling update tracker, but this design would also support additional trackers, such as a webhook update tracker or even a custom test update tracker that developers could implement themselves.This design would make it easier to extend and maintain the library, providing a cleaner separation of responsibilities. It would also allow developers to integrate webhooks or other custom update sources seamlessly while still leveraging the existing
UpdateManagerfunctionality.P.S. I'm planning to modify the current UpdateManager to handle Update objects received via webhook. Once I’m done, I’d be happy to share the changes with you, if you're interested.
Beta Was this translation helpful? Give feedback.
All reactions