{"action":"created","comment":{"url":"https://api.github.com/repos/pusher/em-hiredis/pulls/comments/25352407","id":25352407,"diff_hunk":"@@ -0,0 +1,129 @@\n+require 'uri'\n+\n+module EventMachine::Hiredis\n+  # Emits the following events\n+  #\n+  # * :connected - on successful connection or reconnection\n+  # * :reconnected - on successful reconnection\n+  # * :disconnected - no longer connected, when previously in connected state\n+  # * :reconnect_failed(failure_number) - a reconnect attempt failed\n+  #     This event is passed number of failures so far (1,2,3...)\n+  class ConnectionManager\n+    include EventEmitter\n+\n+    TRANSITIONS = [\n+      # first connect call\n+      [ :initial, :connecting ],\n+      # TCP connect, or initialisation commands fail\n+      [ :connecting, :disconnected ],\n+      # Connection ready for use by clients\n+      [ :connecting, :connected ],\n+      # connection lost\n+      [ :connected, :disconnected ],\n+      # attempting automatic reconnect\n+      [ :disconnected, :connecting ],\n+      # all automatic reconnection attempts failed\n+      [ :disconnected, :failed ],\n+      # manual call of reconnect after failure\n+      [ :failed, :connecting ],\n+    ]\n+\n+    def initialize(em, connection_factory)\n+      @em = em\n+      @connection_factory = connection_factory\n+\n+      @reconnect_attempt = 0\n+\n+      @sm = StateMachine.new\n+      TRANSITIONS.each { |t| @sm.transition(*t) }\n+\n+      @sm.on(:connecting, &method(:connect_internal))\n+      @sm.on(:connected, &method(:connected))\n+      @sm.on(:disconnected, &method(:disconnected))\n+      @sm.on(:failed, &method(:perm_failure))","path":"lib/em-hiredis/connection_manager.rb","position":48,"original_position":43,"commit_id":"64dde57b4415477ade8ef959f051ad1ed07d1f79","original_commit_id":"afc9b9d4f4c869376e70e71575c51a6d431742bc","user":{"login":"mdpye","id":404825,"avatar_url":"https://avatars.githubusercontent.com/u/404825?v=3","gravatar_id":"","url":"https://api.github.com/users/mdpye","html_url":"https://github.com/mdpye","followers_url":"https://api.github.com/users/mdpye/followers","following_url":"https://api.github.com/users/mdpye/following{/other_user}","gists_url":"https://api.github.com/users/mdpye/gists{/gist_id}","starred_url":"https://api.github.com/users/mdpye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdpye/subscriptions","organizations_url":"https://api.github.com/users/mdpye/orgs","repos_url":"https://api.github.com/users/mdpye/repos","events_url":"https://api.github.com/users/mdpye/events{/privacy}","received_events_url":"https://api.github.com/users/mdpye/received_events","type":"User","site_admin":false},"body":"The methods? Yeah.","created_at":"2015-02-25T16:14:13Z","updated_at":"2015-02-25T16:14:13Z","html_url":"https://github.com/pusher/em-hiredis/pull/6#discussion_r25352407","pull_request_url":"https://api.github.com/repos/pusher/em-hiredis/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/pusher/em-hiredis/pulls/comments/25352407"},"html":{"href":"https://github.com/pusher/em-hiredis/pull/6#discussion_r25352407"},"pull_request":{"href":"https://api.github.com/repos/pusher/em-hiredis/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/pusher/em-hiredis/pulls/6","id":29196612,"html_url":"https://github.com/pusher/em-hiredis/pull/6","diff_url":"https://github.com/pusher/em-hiredis/pull/6.diff","patch_url":"https://github.com/pusher/em-hiredis/pull/6.patch","issue_url":"https://api.github.com/repos/pusher/em-hiredis/issues/6","number":6,"state":"open","locked":false,"title":"Connection handling","user":{"login":"mdpye","id":404825,"avatar_url":"https://avatars.githubusercontent.com/u/404825?v=3","gravatar_id":"","url":"https://api.github.com/users/mdpye","html_url":"https://github.com/mdpye","followers_url":"https://api.github.com/users/mdpye/followers","following_url":"https://api.github.com/users/mdpye/following{/other_user}","gists_url":"https://api.github.com/users/mdpye/gists{/gist_id}","starred_url":"https://api.github.com/users/mdpye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdpye/subscriptions","organizations_url":"https://api.github.com/users/mdpye/orgs","repos_url":"https://api.github.com/users/mdpye/repos","events_url":"https://api.github.com/users/mdpye/events{/privacy}","received_events_url":"https://api.github.com/users/mdpye/received_events","type":"User","site_admin":false},"body":"The tests still need a lot of cleaning up, pubsub is completely broken and some odd features may be missing (tests to reveal).\r\n\r\nHowever, I'd like feedback on the BaseClient class - is it easier to reason about than the previous version?","created_at":"2015-02-12T17:05:01Z","updated_at":"2015-02-25T16:14:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f22fd5297c95c7dc4d94e083e83d62ad0c1dffd6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pusher/em-hiredis/pulls/6/commits","review_comments_url":"https://api.github.com/repos/pusher/em-hiredis/pulls/6/comments","review_comment_url":"https://api.github.com/repos/pusher/em-hiredis/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pusher/em-hiredis/issues/6/comments","statuses_url":"https://api.github.com/repos/pusher/em-hiredis/statuses/64dde57b4415477ade8ef959f051ad1ed07d1f79","head":{"label":"pusher:connection_handling","ref":"connection_handling","sha":"64dde57b4415477ade8ef959f051ad1ed07d1f79","user":{"login":"pusher","id":739550,"avatar_url":"https://avatars.githubusercontent.com/u/739550?v=3","gravatar_id":"","url":"https://api.github.com/users/pusher","html_url":"https://github.com/pusher","followers_url":"https://api.github.com/users/pusher/followers","following_url":"https://api.github.com/users/pusher/following{/other_user}","gists_url":"https://api.github.com/users/pusher/gists{/gist_id}","starred_url":"https://api.github.com/users/pusher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pusher/subscriptions","organizations_url":"https://api.github.com/users/pusher/orgs","repos_url":"https://api.github.com/users/pusher/repos","events_url":"https://api.github.com/users/pusher/events{/privacy}","received_events_url":"https://api.github.com/users/pusher/received_events","type":"Organization","site_admin":false},"repo":{"id":20408427,"name":"em-hiredis","full_name":"pusher/em-hiredis","owner":{"login":"pusher","id":739550,"avatar_url":"https://avatars.githubusercontent.com/u/739550?v=3","gravatar_id":"","url":"https://api.github.com/users/pusher","html_url":"https://github.com/pusher","followers_url":"https://api.github.com/users/pusher/followers","following_url":"https://api.github.com/users/pusher/following{/other_user}","gists_url":"https://api.github.com/users/pusher/gists{/gist_id}","starred_url":"https://api.github.com/users/pusher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pusher/subscriptions","organizations_url":"https://api.github.com/users/pusher/orgs","repos_url":"https://api.github.com/users/pusher/repos","events_url":"https://api.github.com/users/pusher/events{/privacy}","received_events_url":"https://api.github.com/users/pusher/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pusher/em-hiredis","description":"Eventmachine redis client","fork":true,"url":"https://api.github.com/repos/pusher/em-hiredis","forks_url":"https://api.github.com/repos/pusher/em-hiredis/forks","keys_url":"https://api.github.com/repos/pusher/em-hiredis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pusher/em-hiredis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pusher/em-hiredis/teams","hooks_url":"https://api.github.com/repos/pusher/em-hiredis/hooks","issue_events_url":"https://api.github.com/repos/pusher/em-hiredis/issues/events{/number}","events_url":"https://api.github.com/repos/pusher/em-hiredis/events","assignees_url":"https://api.github.com/repos/pusher/em-hiredis/assignees{/user}","branches_url":"https://api.github.com/repos/pusher/em-hiredis/branches{/branch}","tags_url":"https://api.github.com/repos/pusher/em-hiredis/tags","blobs_url":"https://api.github.com/repos/pusher/em-hiredis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pusher/em-hiredis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pusher/em-hiredis/git/refs{/sha}","trees_url":"https://api.github.com/repos/pusher/em-hiredis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pusher/em-hiredis/statuses/{sha}","languages_url":"https://api.github.com/repos/pusher/em-hiredis/languages","stargazers_url":"https://api.github.com/repos/pusher/em-hiredis/stargazers","contributors_url":"https://api.github.com/repos/pusher/em-hiredis/contributors","subscribers_url":"https://api.github.com/repos/pusher/em-hiredis/subscribers","subscription_url":"https://api.github.com/repos/pusher/em-hiredis/subscription","commits_url":"https://api.github.com/repos/pusher/em-hiredis/commits{/sha}","git_commits_url":"https://api.github.com/repos/pusher/em-hiredis/git/commits{/sha}","comments_url":"https://api.github.com/repos/pusher/em-hiredis/comments{/number}","issue_comment_url":"https://api.github.com/repos/pusher/em-hiredis/issues/comments{/number}","contents_url":"https://api.github.com/repos/pusher/em-hiredis/contents/{+path}","compare_url":"https://api.github.com/repos/pusher/em-hiredis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pusher/em-hiredis/merges","archive_url":"https://api.github.com/repos/pusher/em-hiredis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pusher/em-hiredis/downloads","issues_url":"https://api.github.com/repos/pusher/em-hiredis/issues{/number}","pulls_url":"https://api.github.com/repos/pusher/em-hiredis/pulls{/number}","milestones_url":"https://api.github.com/repos/pusher/em-hiredis/milestones{/number}","notifications_url":"https://api.github.com/repos/pusher/em-hiredis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pusher/em-hiredis/labels{/name}","releases_url":"https://api.github.com/repos/pusher/em-hiredis/releases{/id}","created_at":"2014-06-02T15:16:04Z","updated_at":"2015-02-17T15:35:41Z","pushed_at":"2015-02-25T16:13:13Z","git_url":"git://github.com/pusher/em-hiredis.git","ssh_url":"git@github.com:pusher/em-hiredis.git","clone_url":"https://github.com/pusher/em-hiredis.git","svn_url":"https://github.com/pusher/em-hiredis","homepage":"","size":614,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"pusher:master","ref":"master","sha":"49304a67db40f214751ba61de1b5b136c8c401c7","user":{"login":"pusher","id":739550,"avatar_url":"https://avatars.githubusercontent.com/u/739550?v=3","gravatar_id":"","url":"https://api.github.com/users/pusher","html_url":"https://github.com/pusher","followers_url":"https://api.github.com/users/pusher/followers","following_url":"https://api.github.com/users/pusher/following{/other_user}","gists_url":"https://api.github.com/users/pusher/gists{/gist_id}","starred_url":"https://api.github.com/users/pusher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pusher/subscriptions","organizations_url":"https://api.github.com/users/pusher/orgs","repos_url":"https://api.github.com/users/pusher/repos","events_url":"https://api.github.com/users/pusher/events{/privacy}","received_events_url":"https://api.github.com/users/pusher/received_events","type":"Organization","site_admin":false},"repo":{"id":20408427,"name":"em-hiredis","full_name":"pusher/em-hiredis","owner":{"login":"pusher","id":739550,"avatar_url":"https://avatars.githubusercontent.com/u/739550?v=3","gravatar_id":"","url":"https://api.github.com/users/pusher","html_url":"https://github.com/pusher","followers_url":"https://api.github.com/users/pusher/followers","following_url":"https://api.github.com/users/pusher/following{/other_user}","gists_url":"https://api.github.com/users/pusher/gists{/gist_id}","starred_url":"https://api.github.com/users/pusher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pusher/subscriptions","organizations_url":"https://api.github.com/users/pusher/orgs","repos_url":"https://api.github.com/users/pusher/repos","events_url":"https://api.github.com/users/pusher/events{/privacy}","received_events_url":"https://api.github.com/users/pusher/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pusher/em-hiredis","description":"Eventmachine redis client","fork":true,"url":"https://api.github.com/repos/pusher/em-hiredis","forks_url":"https://api.github.com/repos/pusher/em-hiredis/forks","keys_url":"https://api.github.com/repos/pusher/em-hiredis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pusher/em-hiredis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pusher/em-hiredis/teams","hooks_url":"https://api.github.com/repos/pusher/em-hiredis/hooks","issue_events_url":"https://api.github.com/repos/pusher/em-hiredis/issues/events{/number}","events_url":"https://api.github.com/repos/pusher/em-hiredis/events","assignees_url":"https://api.github.com/repos/pusher/em-hiredis/assignees{/user}","branches_url":"https://api.github.com/repos/pusher/em-hiredis/branches{/branch}","tags_url":"https://api.github.com/repos/pusher/em-hiredis/tags","blobs_url":"https://api.github.com/repos/pusher/em-hiredis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pusher/em-hiredis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pusher/em-hiredis/git/refs{/sha}","trees_url":"https://api.github.com/repos/pusher/em-hiredis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pusher/em-hiredis/statuses/{sha}","languages_url":"https://api.github.com/repos/pusher/em-hiredis/languages","stargazers_url":"https://api.github.com/repos/pusher/em-hiredis/stargazers","contributors_url":"https://api.github.com/repos/pusher/em-hiredis/contributors","subscribers_url":"https://api.github.com/repos/pusher/em-hiredis/subscribers","subscription_url":"https://api.github.com/repos/pusher/em-hiredis/subscription","commits_url":"https://api.github.com/repos/pusher/em-hiredis/commits{/sha}","git_commits_url":"https://api.github.com/repos/pusher/em-hiredis/git/commits{/sha}","comments_url":"https://api.github.com/repos/pusher/em-hiredis/comments{/number}","issue_comment_url":"https://api.github.com/repos/pusher/em-hiredis/issues/comments{/number}","contents_url":"https://api.github.com/repos/pusher/em-hiredis/contents/{+path}","compare_url":"https://api.github.com/repos/pusher/em-hiredis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pusher/em-hiredis/merges","archive_url":"https://api.github.com/repos/pusher/em-hiredis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pusher/em-hiredis/downloads","issues_url":"https://api.github.com/repos/pusher/em-hiredis/issues{/number}","pulls_url":"https://api.github.com/repos/pusher/em-hiredis/pulls{/number}","milestones_url":"https://api.github.com/repos/pusher/em-hiredis/milestones{/number}","notifications_url":"https://api.github.com/repos/pusher/em-hiredis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pusher/em-hiredis/labels{/name}","releases_url":"https://api.github.com/repos/pusher/em-hiredis/releases{/id}","created_at":"2014-06-02T15:16:04Z","updated_at":"2015-02-17T15:35:41Z","pushed_at":"2015-02-25T16:13:13Z","git_url":"git://github.com/pusher/em-hiredis.git","ssh_url":"git@github.com:pusher/em-hiredis.git","clone_url":"https://github.com/pusher/em-hiredis.git","svn_url":"https://github.com/pusher/em-hiredis","homepage":"","size":614,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pusher/em-hiredis/pulls/6"},"html":{"href":"https://github.com/pusher/em-hiredis/pull/6"},"issue":{"href":"https://api.github.com/repos/pusher/em-hiredis/issues/6"},"comments":{"href":"https://api.github.com/repos/pusher/em-hiredis/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/pusher/em-hiredis/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/pusher/em-hiredis/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pusher/em-hiredis/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/pusher/em-hiredis/statuses/64dde57b4415477ade8ef959f051ad1ed07d1f79"}}}}