{"action":"created","comment":{"url":"https://api.github.com/repos/Runnable/hermes/pulls/comments/43828592","id":43828592,"diff_hunk":"@@ -275,30 +288,57 @@ Hermes.prototype.connect = function (cb) {\n       err.reason = 'connection error';\n       _this.emit('error', err);\n     });\n-    conn.createChannel(function (err, ch) {\n+    _this._createChannel(cb);\n+  });\n+  return this;\n+};\n+\n+Hermes.prototype._createChannel = function (cb) {\n+  var _this = this;\n+  _this._connection.createChannel(function (err, ch) {\n+    if (err) { return cb(err); }\n+    debug('rabbitmq channel created');\n+    /**\n+     * Durable queue: https://www.rabbitmq.com/tutorials/tutorial-two-python.html\n+     * (Message Durability)\n+     */","path":"index.js","position":86,"original_position":86,"commit_id":"cc8120b4103e8d11f6fd883b1017c844695c547b","original_commit_id":"cc8120b4103e8d11f6fd883b1017c844695c547b","user":{"login":"podviaznikov","id":429706,"avatar_url":"https://avatars.githubusercontent.com/u/429706?v=3","gravatar_id":"","url":"https://api.github.com/users/podviaznikov","html_url":"https://github.com/podviaznikov","followers_url":"https://api.github.com/users/podviaznikov/followers","following_url":"https://api.github.com/users/podviaznikov/following{/other_user}","gists_url":"https://api.github.com/users/podviaznikov/gists{/gist_id}","starred_url":"https://api.github.com/users/podviaznikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/podviaznikov/subscriptions","organizations_url":"https://api.github.com/users/podviaznikov/orgs","repos_url":"https://api.github.com/users/podviaznikov/repos","events_url":"https://api.github.com/users/podviaznikov/events{/privacy}","received_events_url":"https://api.github.com/users/podviaznikov/received_events","type":"User","site_admin":false},"body":"is this comment valid about Durability?","created_at":"2015-11-04T00:35:15Z","updated_at":"2015-11-04T00:35:15Z","html_url":"https://github.com/Runnable/hermes/pull/28#discussion_r43828592","pull_request_url":"https://api.github.com/repos/Runnable/hermes/pulls/28","_links":{"self":{"href":"https://api.github.com/repos/Runnable/hermes/pulls/comments/43828592"},"html":{"href":"https://github.com/Runnable/hermes/pull/28#discussion_r43828592"},"pull_request":{"href":"https://api.github.com/repos/Runnable/hermes/pulls/28"}}},"pull_request":{"url":"https://api.github.com/repos/Runnable/hermes/pulls/28","id":49512976,"html_url":"https://github.com/Runnable/hermes/pull/28","diff_url":"https://github.com/Runnable/hermes/pull/28.diff","patch_url":"https://github.com/Runnable/hermes/pull/28.patch","issue_url":"https://api.github.com/repos/Runnable/hermes/issues/28","number":28,"state":"open","locked":false,"title":"make rabbitmq handle events","user":{"login":"anandkumarpatel","id":2194285,"avatar_url":"https://avatars.githubusercontent.com/u/2194285?v=3","gravatar_id":"","url":"https://api.github.com/users/anandkumarpatel","html_url":"https://github.com/anandkumarpatel","followers_url":"https://api.github.com/users/anandkumarpatel/followers","following_url":"https://api.github.com/users/anandkumarpatel/following{/other_user}","gists_url":"https://api.github.com/users/anandkumarpatel/gists{/gist_id}","starred_url":"https://api.github.com/users/anandkumarpatel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anandkumarpatel/subscriptions","organizations_url":"https://api.github.com/users/anandkumarpatel/orgs","repos_url":"https://api.github.com/users/anandkumarpatel/repos","events_url":"https://api.github.com/users/anandkumarpatel/events{/privacy}","received_events_url":"https://api.github.com/users/anandkumarpatel/received_events","type":"User","site_admin":false},"body":"we are now needing to have more then one listener per \"event\" in order to do this we need to start publishing to exchanges.\r\n\r\nThis change is an opinionated way to do Pub/Sub events using `rabbitmq` I chose this way so we can have a uniform way to pass messages across the system without worrying about implementation details. This also provides a layer of abstraction between the queue service and the client  (ex we could swap out for redis events or some other event / broker application) We also follow the node style of event emitter because that is what we are building here.\r\n\r\nI am adding this new functionality while retaining old methods. \r\n\r\nTo use this new functionality you need to define the queues up front. I did this for two reasons\r\n1. We have queue information during initialization\r\n2. because of above we will fail early if we cannot assert queues.\r\n\r\nas part of the options object we will add \r\n`publishedEvents` and `subscribedEvents` which are arrays of the names of events we care about.\r\n\r\nto publish events we use the same api. `client.publish('event', data)`\r\n\r\nto subscribe to events you also use same api `client.subscribe('event', cb)`\r\n","created_at":"2015-11-03T02:18:31Z","updated_at":"2015-11-04T00:35:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4369e1e9c52ea97aaf93849e81dc31c43029fc0c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Runnable/hermes/pulls/28/commits","review_comments_url":"https://api.github.com/repos/Runnable/hermes/pulls/28/comments","review_comment_url":"https://api.github.com/repos/Runnable/hermes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Runnable/hermes/issues/28/comments","statuses_url":"https://api.github.com/repos/Runnable/hermes/statuses/cc8120b4103e8d11f6fd883b1017c844695c547b","head":{"label":"Runnable:fanout-exchange","ref":"fanout-exchange","sha":"cc8120b4103e8d11f6fd883b1017c844695c547b","user":{"login":"Runnable","id":2828361,"avatar_url":"https://avatars.githubusercontent.com/u/2828361?v=3","gravatar_id":"","url":"https://api.github.com/users/Runnable","html_url":"https://github.com/Runnable","followers_url":"https://api.github.com/users/Runnable/followers","following_url":"https://api.github.com/users/Runnable/following{/other_user}","gists_url":"https://api.github.com/users/Runnable/gists{/gist_id}","starred_url":"https://api.github.com/users/Runnable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Runnable/subscriptions","organizations_url":"https://api.github.com/users/Runnable/orgs","repos_url":"https://api.github.com/users/Runnable/repos","events_url":"https://api.github.com/users/Runnable/events{/privacy}","received_events_url":"https://api.github.com/users/Runnable/received_events","type":"Organization","site_admin":false},"repo":{"id":33754161,"name":"hermes","full_name":"Runnable/hermes","owner":{"login":"Runnable","id":2828361,"avatar_url":"https://avatars.githubusercontent.com/u/2828361?v=3","gravatar_id":"","url":"https://api.github.com/users/Runnable","html_url":"https://github.com/Runnable","followers_url":"https://api.github.com/users/Runnable/followers","following_url":"https://api.github.com/users/Runnable/following{/other_user}","gists_url":"https://api.github.com/users/Runnable/gists{/gist_id}","starred_url":"https://api.github.com/users/Runnable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Runnable/subscriptions","organizations_url":"https://api.github.com/users/Runnable/orgs","repos_url":"https://api.github.com/users/Runnable/repos","events_url":"https://api.github.com/users/Runnable/events{/privacy}","received_events_url":"https://api.github.com/users/Runnable/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Runnable/hermes","description":"Runnable job queuing system interface abstraction for runnable's services","fork":false,"url":"https://api.github.com/repos/Runnable/hermes","forks_url":"https://api.github.com/repos/Runnable/hermes/forks","keys_url":"https://api.github.com/repos/Runnable/hermes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Runnable/hermes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Runnable/hermes/teams","hooks_url":"https://api.github.com/repos/Runnable/hermes/hooks","issue_events_url":"https://api.github.com/repos/Runnable/hermes/issues/events{/number}","events_url":"https://api.github.com/repos/Runnable/hermes/events","assignees_url":"https://api.github.com/repos/Runnable/hermes/assignees{/user}","branches_url":"https://api.github.com/repos/Runnable/hermes/branches{/branch}","tags_url":"https://api.github.com/repos/Runnable/hermes/tags","blobs_url":"https://api.github.com/repos/Runnable/hermes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Runnable/hermes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Runnable/hermes/git/refs{/sha}","trees_url":"https://api.github.com/repos/Runnable/hermes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Runnable/hermes/statuses/{sha}","languages_url":"https://api.github.com/repos/Runnable/hermes/languages","stargazers_url":"https://api.github.com/repos/Runnable/hermes/stargazers","contributors_url":"https://api.github.com/repos/Runnable/hermes/contributors","subscribers_url":"https://api.github.com/repos/Runnable/hermes/subscribers","subscription_url":"https://api.github.com/repos/Runnable/hermes/subscription","commits_url":"https://api.github.com/repos/Runnable/hermes/commits{/sha}","git_commits_url":"https://api.github.com/repos/Runnable/hermes/git/commits{/sha}","comments_url":"https://api.github.com/repos/Runnable/hermes/comments{/number}","issue_comment_url":"https://api.github.com/repos/Runnable/hermes/issues/comments{/number}","contents_url":"https://api.github.com/repos/Runnable/hermes/contents/{+path}","compare_url":"https://api.github.com/repos/Runnable/hermes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Runnable/hermes/merges","archive_url":"https://api.github.com/repos/Runnable/hermes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Runnable/hermes/downloads","issues_url":"https://api.github.com/repos/Runnable/hermes/issues{/number}","pulls_url":"https://api.github.com/repos/Runnable/hermes/pulls{/number}","milestones_url":"https://api.github.com/repos/Runnable/hermes/milestones{/number}","notifications_url":"https://api.github.com/repos/Runnable/hermes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Runnable/hermes/labels{/name}","releases_url":"https://api.github.com/repos/Runnable/hermes/releases{/id}","created_at":"2015-04-10T22:48:44Z","updated_at":"2015-08-08T00:49:40Z","pushed_at":"2015-11-03T22:58:30Z","git_url":"git://github.com/Runnable/hermes.git","ssh_url":"git@github.com:Runnable/hermes.git","clone_url":"https://github.com/Runnable/hermes.git","svn_url":"https://github.com/Runnable/hermes","homepage":null,"size":644,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":3,"default_branch":"master"}},"base":{"label":"Runnable:master","ref":"master","sha":"c73f9a04656fc76a09d95c113dbf177e95a2b73d","user":{"login":"Runnable","id":2828361,"avatar_url":"https://avatars.githubusercontent.com/u/2828361?v=3","gravatar_id":"","url":"https://api.github.com/users/Runnable","html_url":"https://github.com/Runnable","followers_url":"https://api.github.com/users/Runnable/followers","following_url":"https://api.github.com/users/Runnable/following{/other_user}","gists_url":"https://api.github.com/users/Runnable/gists{/gist_id}","starred_url":"https://api.github.com/users/Runnable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Runnable/subscriptions","organizations_url":"https://api.github.com/users/Runnable/orgs","repos_url":"https://api.github.com/users/Runnable/repos","events_url":"https://api.github.com/users/Runnable/events{/privacy}","received_events_url":"https://api.github.com/users/Runnable/received_events","type":"Organization","site_admin":false},"repo":{"id":33754161,"name":"hermes","full_name":"Runnable/hermes","owner":{"login":"Runnable","id":2828361,"avatar_url":"https://avatars.githubusercontent.com/u/2828361?v=3","gravatar_id":"","url":"https://api.github.com/users/Runnable","html_url":"https://github.com/Runnable","followers_url":"https://api.github.com/users/Runnable/followers","following_url":"https://api.github.com/users/Runnable/following{/other_user}","gists_url":"https://api.github.com/users/Runnable/gists{/gist_id}","starred_url":"https://api.github.com/users/Runnable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Runnable/subscriptions","organizations_url":"https://api.github.com/users/Runnable/orgs","repos_url":"https://api.github.com/users/Runnable/repos","events_url":"https://api.github.com/users/Runnable/events{/privacy}","received_events_url":"https://api.github.com/users/Runnable/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Runnable/hermes","description":"Runnable job queuing system interface abstraction for runnable's services","fork":false,"url":"https://api.github.com/repos/Runnable/hermes","forks_url":"https://api.github.com/repos/Runnable/hermes/forks","keys_url":"https://api.github.com/repos/Runnable/hermes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Runnable/hermes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Runnable/hermes/teams","hooks_url":"https://api.github.com/repos/Runnable/hermes/hooks","issue_events_url":"https://api.github.com/repos/Runnable/hermes/issues/events{/number}","events_url":"https://api.github.com/repos/Runnable/hermes/events","assignees_url":"https://api.github.com/repos/Runnable/hermes/assignees{/user}","branches_url":"https://api.github.com/repos/Runnable/hermes/branches{/branch}","tags_url":"https://api.github.com/repos/Runnable/hermes/tags","blobs_url":"https://api.github.com/repos/Runnable/hermes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Runnable/hermes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Runnable/hermes/git/refs{/sha}","trees_url":"https://api.github.com/repos/Runnable/hermes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Runnable/hermes/statuses/{sha}","languages_url":"https://api.github.com/repos/Runnable/hermes/languages","stargazers_url":"https://api.github.com/repos/Runnable/hermes/stargazers","contributors_url":"https://api.github.com/repos/Runnable/hermes/contributors","subscribers_url":"https://api.github.com/repos/Runnable/hermes/subscribers","subscription_url":"https://api.github.com/repos/Runnable/hermes/subscription","commits_url":"https://api.github.com/repos/Runnable/hermes/commits{/sha}","git_commits_url":"https://api.github.com/repos/Runnable/hermes/git/commits{/sha}","comments_url":"https://api.github.com/repos/Runnable/hermes/comments{/number}","issue_comment_url":"https://api.github.com/repos/Runnable/hermes/issues/comments{/number}","contents_url":"https://api.github.com/repos/Runnable/hermes/contents/{+path}","compare_url":"https://api.github.com/repos/Runnable/hermes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Runnable/hermes/merges","archive_url":"https://api.github.com/repos/Runnable/hermes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Runnable/hermes/downloads","issues_url":"https://api.github.com/repos/Runnable/hermes/issues{/number}","pulls_url":"https://api.github.com/repos/Runnable/hermes/pulls{/number}","milestones_url":"https://api.github.com/repos/Runnable/hermes/milestones{/number}","notifications_url":"https://api.github.com/repos/Runnable/hermes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Runnable/hermes/labels{/name}","releases_url":"https://api.github.com/repos/Runnable/hermes/releases{/id}","created_at":"2015-04-10T22:48:44Z","updated_at":"2015-08-08T00:49:40Z","pushed_at":"2015-11-03T22:58:30Z","git_url":"git://github.com/Runnable/hermes.git","ssh_url":"git@github.com:Runnable/hermes.git","clone_url":"https://github.com/Runnable/hermes.git","svn_url":"https://github.com/Runnable/hermes","homepage":null,"size":644,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Runnable/hermes/pulls/28"},"html":{"href":"https://github.com/Runnable/hermes/pull/28"},"issue":{"href":"https://api.github.com/repos/Runnable/hermes/issues/28"},"comments":{"href":"https://api.github.com/repos/Runnable/hermes/issues/28/comments"},"review_comments":{"href":"https://api.github.com/repos/Runnable/hermes/pulls/28/comments"},"review_comment":{"href":"https://api.github.com/repos/Runnable/hermes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Runnable/hermes/pulls/28/commits"},"statuses":{"href":"https://api.github.com/repos/Runnable/hermes/statuses/cc8120b4103e8d11f6fd883b1017c844695c547b"}}}}