{"action":"created","comment":{"url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/pulls/comments/27167285","id":27167285,"diff_hunk":"@@ -241,93 +220,92 @@ managedKinesisConsumer kit =\n -- it.\n --\n withKinesisConsumer\n-  ∷ MonadConsumer m\n+  ∷ ( MonadIO m\n+    , MonadBaseControl IO m\n+    )\n   ⇒ ConsumerKit\n   → (KinesisConsumer → m α)\n   → m α\n-withKinesisConsumer kit inner =\n-  flip runReaderT kit $ do\n-    batchSize ← view ckBatchSize\n-    messageQueue ← liftIO ∘ newTBQueueIO $ batchSize * 10\n-\n-    state ← updateStreamState CR.empty ≫= liftIO ∘ newTVarIO\n-    let reshardingLoop = forever $\n-          handleError (\\_ → liftIO $ threadDelay 3000000) $ do\n-            liftIO (readTVarIO state)\n-              ≫= updateStreamState\n-              ≫= liftIO ∘ atomically ∘ writeTVar state\n-            liftIO $ threadDelay 10000000\n-\n-        producerLoop = forever $\n-          handleError (\\_ → liftIO $ threadDelay 2000000) $ do\n-            recordsCount ← replenishMessages messageQueue state\n-            liftIO ∘ threadDelay $\n-              case recordsCount of\n-                0 → 5000000\n-                _ → 70000\n-\n-\n-    withAsync reshardingLoop $ \\reshardingHandle → do\n-      link reshardingHandle\n-      withAsync producerLoop $ \\producerHandle → do\n-        link producerHandle\n-        res ← lift ∘ inner $ KinesisConsumer messageQueue state\n-        return res\n+withKinesisConsumer kit inner = do\n+  let batchSize = kit ^. ckBatchSize\n+  messageQueue ← liftIO ∘ newTBQueueIO $ batchSize * 10\n+\n+  state ← liftIO $ updateStreamState kit CR.empty ≫= newTVarIO\n+\n+  let\n+    reshardingLoop =\n+      forever ∘ handle (\\(SomeException _) → threadDelay 3000000) $ do","path":"src/Aws/Kinesis/Client/Consumer.hs","position":116,"original_position":116,"commit_id":"469fea14d5c575b203847141defe639744f76c99","original_commit_id":"6ebc25d44d9976f2193f71c2d8a1c72ec7797645","user":{"login":"larskuhtz","id":1369810,"avatar_url":"https://avatars.githubusercontent.com/u/1369810?v=3","gravatar_id":"","url":"https://api.github.com/users/larskuhtz","html_url":"https://github.com/larskuhtz","followers_url":"https://api.github.com/users/larskuhtz/followers","following_url":"https://api.github.com/users/larskuhtz/following{/other_user}","gists_url":"https://api.github.com/users/larskuhtz/gists{/gist_id}","starred_url":"https://api.github.com/users/larskuhtz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larskuhtz/subscriptions","organizations_url":"https://api.github.com/users/larskuhtz/orgs","repos_url":"https://api.github.com/users/larskuhtz/repos","events_url":"https://api.github.com/users/larskuhtz/events{/privacy}","received_events_url":"https://api.github.com/users/larskuhtz/received_events","type":"User","site_admin":false},"body":"I am always a little concerned when I see this kind of loops, in particular in a thread. If there is chance that the system goes into a bad state, this could loop forever without doing reasonable work while the reset of the system is working under the assumption that this component does it's job. It seems that `updateStreamState` is doing network IO, which could be vulnerable to such an situation. For instance the name resolution may get into a state of permanent failure. \r\n\r\nIf this would happen, is there a mechanism that would notify the overall system and trigger appropriate actions?","created_at":"2015-03-25T21:20:15Z","updated_at":"2015-03-25T21:20:15Z","html_url":"https://github.com/alephcloud/hs-aws-kinesis-client/pull/20#discussion_r27167285","pull_request_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/pulls/20","_links":{"self":{"href":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/pulls/comments/27167285"},"html":{"href":"https://github.com/alephcloud/hs-aws-kinesis-client/pull/20#discussion_r27167285"},"pull_request":{"href":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/pulls/20"}}},"pull_request":{"url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/pulls/20","id":31784739,"html_url":"https://github.com/alephcloud/hs-aws-kinesis-client/pull/20","diff_url":"https://github.com/alephcloud/hs-aws-kinesis-client/pull/20.diff","patch_url":"https://github.com/alephcloud/hs-aws-kinesis-client/pull/20.patch","issue_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/issues/20","number":20,"state":"open","locked":false,"title":"Breaking changes: improved shutdown and error approach","user":{"login":"jonsterling","id":55057,"avatar_url":"https://avatars.githubusercontent.com/u/55057?v=3","gravatar_id":"","url":"https://api.github.com/users/jonsterling","html_url":"https://github.com/jonsterling","followers_url":"https://api.github.com/users/jonsterling/followers","following_url":"https://api.github.com/users/jonsterling/following{/other_user}","gists_url":"https://api.github.com/users/jonsterling/gists{/gist_id}","starred_url":"https://api.github.com/users/jonsterling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonsterling/subscriptions","organizations_url":"https://api.github.com/users/jonsterling/orgs","repos_url":"https://api.github.com/users/jonsterling/repos","events_url":"https://api.github.com/users/jonsterling/events{/privacy}","received_events_url":"https://api.github.com/users/jonsterling/received_events","type":"User","site_admin":false},"body":"This is intended to address #19 and #17\r\n\r\nThere is more to be done before this may be merged.\r\n\r\n- [x] stop plumbing exceptions into `MonadError`\r\n- [x] remove `either` dependency\r\n- [x] expose possibly-throwing functions as returning `m (Either e a)`\r\n- [x] use `enclosed-exceptions` where appropriate\r\n- [x] implement graceful shutdown of producer \r\n- [x] add configurable timeout for producer worker cleanup\r\n- [x] update changelog","created_at":"2015-03-23T23:34:26Z","updated_at":"2015-03-25T21:20:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d421916e566dbb56f71e787f9f4a7a3286823b6e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/pulls/20/commits","review_comments_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/pulls/20/comments","review_comment_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/issues/20/comments","statuses_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/statuses/469fea14d5c575b203847141defe639744f76c99","head":{"label":"alephcloud:js/errors-and-shutdown","ref":"js/errors-and-shutdown","sha":"469fea14d5c575b203847141defe639744f76c99","user":{"login":"alephcloud","id":1145376,"avatar_url":"https://avatars.githubusercontent.com/u/1145376?v=3","gravatar_id":"","url":"https://api.github.com/users/alephcloud","html_url":"https://github.com/alephcloud","followers_url":"https://api.github.com/users/alephcloud/followers","following_url":"https://api.github.com/users/alephcloud/following{/other_user}","gists_url":"https://api.github.com/users/alephcloud/gists{/gist_id}","starred_url":"https://api.github.com/users/alephcloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alephcloud/subscriptions","organizations_url":"https://api.github.com/users/alephcloud/orgs","repos_url":"https://api.github.com/users/alephcloud/repos","events_url":"https://api.github.com/users/alephcloud/events{/privacy}","received_events_url":"https://api.github.com/users/alephcloud/received_events","type":"Organization","site_admin":false},"repo":{"id":28429911,"name":"hs-aws-kinesis-client","full_name":"alephcloud/hs-aws-kinesis-client","owner":{"login":"alephcloud","id":1145376,"avatar_url":"https://avatars.githubusercontent.com/u/1145376?v=3","gravatar_id":"","url":"https://api.github.com/users/alephcloud","html_url":"https://github.com/alephcloud","followers_url":"https://api.github.com/users/alephcloud/followers","following_url":"https://api.github.com/users/alephcloud/following{/other_user}","gists_url":"https://api.github.com/users/alephcloud/gists{/gist_id}","starred_url":"https://api.github.com/users/alephcloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alephcloud/subscriptions","organizations_url":"https://api.github.com/users/alephcloud/orgs","repos_url":"https://api.github.com/users/alephcloud/repos","events_url":"https://api.github.com/users/alephcloud/events{/privacy}","received_events_url":"https://api.github.com/users/alephcloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alephcloud/hs-aws-kinesis-client","description":"A producer/consumer client library for Kinesis","fork":false,"url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client","forks_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/forks","keys_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/teams","hooks_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/hooks","issue_events_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/issues/events{/number}","events_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/events","assignees_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/assignees{/user}","branches_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/branches{/branch}","tags_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/tags","blobs_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/statuses/{sha}","languages_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/languages","stargazers_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/stargazers","contributors_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/contributors","subscribers_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/subscribers","subscription_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/subscription","commits_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/contents/{+path}","compare_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/merges","archive_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/downloads","issues_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/issues{/number}","pulls_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/pulls{/number}","milestones_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/milestones{/number}","notifications_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/labels{/name}","releases_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/releases{/id}","created_at":"2014-12-24T02:16:36Z","updated_at":"2015-03-20T20:16:51Z","pushed_at":"2015-03-25T21:01:39Z","git_url":"git://github.com/alephcloud/hs-aws-kinesis-client.git","ssh_url":"git@github.com:alephcloud/hs-aws-kinesis-client.git","clone_url":"https://github.com/alephcloud/hs-aws-kinesis-client.git","svn_url":"https://github.com/alephcloud/hs-aws-kinesis-client","homepage":"http://hackage.haskell.org/package/aws-kinesis-client","size":678,"stargazers_count":1,"watchers_count":1,"language":"Haskell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":1,"default_branch":"master"}},"base":{"label":"alephcloud:master","ref":"master","sha":"d292fc8b1c6dad4ac00e0d50afb1bc4b7418938f","user":{"login":"alephcloud","id":1145376,"avatar_url":"https://avatars.githubusercontent.com/u/1145376?v=3","gravatar_id":"","url":"https://api.github.com/users/alephcloud","html_url":"https://github.com/alephcloud","followers_url":"https://api.github.com/users/alephcloud/followers","following_url":"https://api.github.com/users/alephcloud/following{/other_user}","gists_url":"https://api.github.com/users/alephcloud/gists{/gist_id}","starred_url":"https://api.github.com/users/alephcloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alephcloud/subscriptions","organizations_url":"https://api.github.com/users/alephcloud/orgs","repos_url":"https://api.github.com/users/alephcloud/repos","events_url":"https://api.github.com/users/alephcloud/events{/privacy}","received_events_url":"https://api.github.com/users/alephcloud/received_events","type":"Organization","site_admin":false},"repo":{"id":28429911,"name":"hs-aws-kinesis-client","full_name":"alephcloud/hs-aws-kinesis-client","owner":{"login":"alephcloud","id":1145376,"avatar_url":"https://avatars.githubusercontent.com/u/1145376?v=3","gravatar_id":"","url":"https://api.github.com/users/alephcloud","html_url":"https://github.com/alephcloud","followers_url":"https://api.github.com/users/alephcloud/followers","following_url":"https://api.github.com/users/alephcloud/following{/other_user}","gists_url":"https://api.github.com/users/alephcloud/gists{/gist_id}","starred_url":"https://api.github.com/users/alephcloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alephcloud/subscriptions","organizations_url":"https://api.github.com/users/alephcloud/orgs","repos_url":"https://api.github.com/users/alephcloud/repos","events_url":"https://api.github.com/users/alephcloud/events{/privacy}","received_events_url":"https://api.github.com/users/alephcloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alephcloud/hs-aws-kinesis-client","description":"A producer/consumer client library for Kinesis","fork":false,"url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client","forks_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/forks","keys_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/teams","hooks_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/hooks","issue_events_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/issues/events{/number}","events_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/events","assignees_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/assignees{/user}","branches_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/branches{/branch}","tags_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/tags","blobs_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/statuses/{sha}","languages_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/languages","stargazers_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/stargazers","contributors_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/contributors","subscribers_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/subscribers","subscription_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/subscription","commits_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/contents/{+path}","compare_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/merges","archive_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/downloads","issues_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/issues{/number}","pulls_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/pulls{/number}","milestones_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/milestones{/number}","notifications_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/labels{/name}","releases_url":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/releases{/id}","created_at":"2014-12-24T02:16:36Z","updated_at":"2015-03-20T20:16:51Z","pushed_at":"2015-03-25T21:01:39Z","git_url":"git://github.com/alephcloud/hs-aws-kinesis-client.git","ssh_url":"git@github.com:alephcloud/hs-aws-kinesis-client.git","clone_url":"https://github.com/alephcloud/hs-aws-kinesis-client.git","svn_url":"https://github.com/alephcloud/hs-aws-kinesis-client","homepage":"http://hackage.haskell.org/package/aws-kinesis-client","size":678,"stargazers_count":1,"watchers_count":1,"language":"Haskell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/pulls/20"},"html":{"href":"https://github.com/alephcloud/hs-aws-kinesis-client/pull/20"},"issue":{"href":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/issues/20"},"comments":{"href":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/issues/20/comments"},"review_comments":{"href":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/pulls/20/comments"},"review_comment":{"href":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/pulls/20/commits"},"statuses":{"href":"https://api.github.com/repos/alephcloud/hs-aws-kinesis-client/statuses/469fea14d5c575b203847141defe639744f76c99"}}}}