Coder Social home page Coder Social logo

Comments (5)

chshersh avatar chshersh commented on June 3, 2024 1

@rashadg1030 Let's have IW/Sync directory and corresponding IW.Sync.* modules for the forwker. Async and Worker seem to generic. Sync is for synchronisation which is that it should do.

Regarding implementing the worker, I have some suggestions:

Implement a separate function that fetches data for a single repo or for a single issue. In this case we will be able to test such functions from GHCi and check the data in SQL tables. And it's easy to call such functions for all fetched repos.

from issue-wanted.

chshersh avatar chshersh commented on June 3, 2024 1

@rashadg1030 I'm going to describe a high-level overview of the sync algorithm.

Main function should look like this:

syncCache = forever $ syncWithGitHub `catch` \...

So we are trying to sync cache in the infinite loop, handling all errors.

syncWithGitHub function looks like this:

syncWithGitHub = do
    repos <- fetchAllRepos
    upsertRepos
    populateCategoriesAsync <- async $ populateCategories repos
    issues <- fetchAllIssues
    upsertIssues issues
    wait populateCategoriesAsync

The idea is the following:

  1. First, we fetch all the repositories.
  2. Second, we populate categories for repositories in a separate thread.
  3. While we are populating categories, we can update all issues.
  4. Wait while we update all categories.

Does this make sense for now?

from issue-wanted.

rashadg1030 avatar rashadg1030 commented on June 3, 2024 1

@chshersh
I'm gonna use the algorithm you mentioned above now:

syncWithGitHub = do
    repos <- fetchAllRepos
    upsertRepos
    populateCategoriesAsync <- async $ populateCategories repos
    issues <- fetchAllIssues
    upsertIssues issues
    wait populateCategoriesAsync

from issue-wanted.

rashadg1030 avatar rashadg1030 commented on June 3, 2024

@chshersh This is perfect. Thank you!

from issue-wanted.

rashadg1030 avatar rashadg1030 commented on June 3, 2024

@chshersh Now that everything is in place, I'm gonna implement the sync algorithm for issues and then clear this issue. There will be a single function that syncs both repos and issues.

from issue-wanted.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.