Browse Source

Use async-pool in order to limit rate limiting

master
Wesley Kerfoot 5 years ago
parent
commit
8e502da42c
  1. 6
      pullwatch.cabal
  2. 6
      src/PullWatch/PullWatch.hs
  3. 1
      stack.yaml

6
pullwatch.cabal

@ -40,7 +40,7 @@ library
, text
, bytestring
, vector
, async
, async-pool >= 0.9.0
, containers
, yaml
, system-filepath
@ -65,7 +65,7 @@ executable pullwatch-exe
, text
, bytestring
, vector
, async
, async-pool >= 0.9.0
, containers
, yaml
, system-filepath
@ -91,7 +91,7 @@ test-suite pullwatch-test
, text
, bytestring
, vector
, async
, async-pool >= 0.9.0
, containers
, yaml
, data-default

6
src/PullWatch/PullWatch.hs

@ -21,7 +21,7 @@ import GitHub.Data.PullRequests
import Control.Applicative
import Control.Concurrent (threadDelay)
import Control.Concurrent.Async
import Control.Concurrent.Async.Pool
import DBus.Notify
import Data.Maybe
import Data.Vector ((!?))
@ -95,8 +95,8 @@ getLatestPRs :: (?pat :: (Maybe Auth.Auth)) =>
[Repo] ->
IO (Maybe PullRequests)
getLatestPRs repos = do
prs <- mapConcurrently getLatest repos
getLatestPRs repos = withTaskGroup 2 $ \g -> do
prs <- mapConcurrently g getLatest repos
return $ maybesToMap prs
monitorPRs :: (?pat :: (Maybe Auth.Auth)) =>

1
stack.yaml

@ -41,6 +41,7 @@ packages:
extra-deps:
- fdo-notify-0.3.1
- github-0.21
- async-pool-0.9.0
- git: git@github.com:sbergot/ArgParser.git
commit: 801ffac4551382a0b08a50ae3b98402ebbf35b30

Loading…
Cancel
Save