Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Refactor Torrect checker #7328

Closed
wants to merge 21 commits into from

Conversation

xoriole
Copy link
Contributor

@xoriole xoriole commented Mar 20, 2023

Torrent Checker is broken down into two services:

  1. CheckerService: This service is responsible for doing torrent checks using different trackers and DHT and does not deal with any database stuff.
  2. DbService: This service is responsible for saving to and retrieving from the database the torrent health info. This service does not deal with any torrent checking itself.

With checker and persistence related functions delegated to these two services, TorrentChecker becomes a bit more simplified with the following interface

class TorrentChecker:

   # Main function that checks, persists and returns the health info for given infohash
    async def check_torrent_health(self, infohash: bytes, timeout=20, scrape_now=False) -> HealthInfo:

    # Periodic jobs defined in initialize()
    async def check_random_tracker(self):
    async def check_local_torrents(self) -> Tuple[List, List]:
    async def check_torrents_in_user_channel(self) -> List[Union[HealthInfo, BaseException]]:

    async def initialize(self):
        self.register_task("check random tracker", self.check_random_tracker, interval=TRACKER_SELECTION_INTERVAL)
        self.register_task("check local torrents", self.check_local_torrents, interval=TORRENT_SELECTION_INTERVAL)
        self.register_task("check channel torrents", self.check_torrents_in_user_channel, interval=USER_CHANNEL_TORRENT_SELECTION_INTERVAL)
        ...
        
    async def shutdown(self):    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant