{"action":"created","comment":{"url":"https://api.github.com/repos/elasticio/sailor-nodejs/pulls/comments/29331322","id":29331322,"diff_hunk":"@@ -0,0 +1,172 @@\n+var debug = require('debug')('sailor');\n+var amqplib = require('amqplib');\n+var cipher = require('./cipher.js');\n+var Q = require('q');\n+var _ = require('lodash');\n+\n+var AMQPConnection = function(settings) {\n+\n+    var self = this;\n+\n+    self.amqp = null;\n+    self.subscribeChannel = null;\n+    self.publishChannel = null;\n+\n+    self.connect = function connect(uri) {\n+        return openConnection(uri)\n+            .then(openSubscribeChannel)\n+            .then(openPublishChannel)\n+            .then(assertAllQueues);\n+    };\n+\n+    function openConnection(uri) {\n+        return amqplib.connect(uri).then(function(connection){\n+            debug('Connected to AMQP on %s', uri);\n+            self.amqp = connection;\n+        });\n+    }\n+\n+    function openSubscribeChannel() {\n+        debug('Open subscribe channel');\n+        return self.amqp.createChannel().then(function(channel) {\n+            debug('Opened subscribe channel');\n+            self.subscribeChannel = channel;\n+        })\n+    }\n+\n+    function openPublishChannel() {\n+        debug('Open publish channel');\n+        return self.amqp.createChannel().then(function(channel) {\n+            debug('Opened publish channel');\n+            self.publishChannel = channel;\n+        });\n+    }\n+\n+    function assertAllQueues() {\n+        return Q.all([\n+            assertQueue(self.subscribeChannel, settings.INCOMING_MESSAGES_QUEUE),","path":"lib/amqp.js","position":47,"original_position":47,"commit_id":"d6b20ffb662b8a5c9780f603780eaab52cbe8005","original_commit_id":"d6b20ffb662b8a5c9780f603780eaab52cbe8005","user":{"login":"drobiazko","id":464220,"avatar_url":"https://avatars.githubusercontent.com/u/464220?v=3","gravatar_id":"","url":"https://api.github.com/users/drobiazko","html_url":"https://github.com/drobiazko","followers_url":"https://api.github.com/users/drobiazko/followers","following_url":"https://api.github.com/users/drobiazko/following{/other_user}","gists_url":"https://api.github.com/users/drobiazko/gists{/gist_id}","starred_url":"https://api.github.com/users/drobiazko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drobiazko/subscriptions","organizations_url":"https://api.github.com/users/drobiazko/orgs","repos_url":"https://api.github.com/users/drobiazko/repos","events_url":"https://api.github.com/users/drobiazko/events{/privacy}","received_events_url":"https://api.github.com/users/drobiazko/received_events","type":"User","site_admin":false},"body":"What I mean here is: Does it make sense sailor is not responsible for the queue configuration and creation? Shouldn't it happen somewhere else?","created_at":"2015-04-29T12:40:00Z","updated_at":"2015-04-29T12:40:00Z","html_url":"https://github.com/elasticio/sailor-nodejs/pull/1#discussion_r29331322","pull_request_url":"https://api.github.com/repos/elasticio/sailor-nodejs/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/elasticio/sailor-nodejs/pulls/comments/29331322"},"html":{"href":"https://github.com/elasticio/sailor-nodejs/pull/1#discussion_r29331322"},"pull_request":{"href":"https://api.github.com/repos/elasticio/sailor-nodejs/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/elasticio/sailor-nodejs/pulls/1","id":34351407,"html_url":"https://github.com/elasticio/sailor-nodejs/pull/1","diff_url":"https://github.com/elasticio/sailor-nodejs/pull/1.diff","patch_url":"https://github.com/elasticio/sailor-nodejs/pull/1.patch","issue_url":"https://api.github.com/repos/elasticio/sailor-nodejs/issues/1","number":1,"state":"open","locked":false,"title":"Sailor alpha version","user":{"login":"ellenaua","id":6443895,"avatar_url":"https://avatars.githubusercontent.com/u/6443895?v=3","gravatar_id":"","url":"https://api.github.com/users/ellenaua","html_url":"https://github.com/ellenaua","followers_url":"https://api.github.com/users/ellenaua/followers","following_url":"https://api.github.com/users/ellenaua/following{/other_user}","gists_url":"https://api.github.com/users/ellenaua/gists{/gist_id}","starred_url":"https://api.github.com/users/ellenaua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ellenaua/subscriptions","organizations_url":"https://api.github.com/users/ellenaua/orgs","repos_url":"https://api.github.com/users/ellenaua/repos","events_url":"https://api.github.com/users/ellenaua/events{/privacy}","received_events_url":"https://api.github.com/users/ellenaua/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-29T10:52:26Z","updated_at":"2015-04-29T12:40:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7b2de32e5dcff39a7148ef376e360093780c4a19","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elasticio/sailor-nodejs/pulls/1/commits","review_comments_url":"https://api.github.com/repos/elasticio/sailor-nodejs/pulls/1/comments","review_comment_url":"https://api.github.com/repos/elasticio/sailor-nodejs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elasticio/sailor-nodejs/issues/1/comments","statuses_url":"https://api.github.com/repos/elasticio/sailor-nodejs/statuses/d6b20ffb662b8a5c9780f603780eaab52cbe8005","head":{"label":"elasticio:master","ref":"master","sha":"d6b20ffb662b8a5c9780f603780eaab52cbe8005","user":{"login":"elasticio","id":1560253,"avatar_url":"https://avatars.githubusercontent.com/u/1560253?v=3","gravatar_id":"","url":"https://api.github.com/users/elasticio","html_url":"https://github.com/elasticio","followers_url":"https://api.github.com/users/elasticio/followers","following_url":"https://api.github.com/users/elasticio/following{/other_user}","gists_url":"https://api.github.com/users/elasticio/gists{/gist_id}","starred_url":"https://api.github.com/users/elasticio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elasticio/subscriptions","organizations_url":"https://api.github.com/users/elasticio/orgs","repos_url":"https://api.github.com/users/elasticio/repos","events_url":"https://api.github.com/users/elasticio/events{/privacy}","received_events_url":"https://api.github.com/users/elasticio/received_events","type":"Organization","site_admin":false},"repo":{"id":34468171,"name":"sailor-nodejs","full_name":"elasticio/sailor-nodejs","owner":{"login":"elasticio","id":1560253,"avatar_url":"https://avatars.githubusercontent.com/u/1560253?v=3","gravatar_id":"","url":"https://api.github.com/users/elasticio","html_url":"https://github.com/elasticio","followers_url":"https://api.github.com/users/elasticio/followers","following_url":"https://api.github.com/users/elasticio/following{/other_user}","gists_url":"https://api.github.com/users/elasticio/gists{/gist_id}","starred_url":"https://api.github.com/users/elasticio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elasticio/subscriptions","organizations_url":"https://api.github.com/users/elasticio/orgs","repos_url":"https://api.github.com/users/elasticio/repos","events_url":"https://api.github.com/users/elasticio/events{/privacy}","received_events_url":"https://api.github.com/users/elasticio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elasticio/sailor-nodejs","description":"The official elastic.io library for bootstrapping and executing for Node.js connectors.","fork":false,"url":"https://api.github.com/repos/elasticio/sailor-nodejs","forks_url":"https://api.github.com/repos/elasticio/sailor-nodejs/forks","keys_url":"https://api.github.com/repos/elasticio/sailor-nodejs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elasticio/sailor-nodejs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elasticio/sailor-nodejs/teams","hooks_url":"https://api.github.com/repos/elasticio/sailor-nodejs/hooks","issue_events_url":"https://api.github.com/repos/elasticio/sailor-nodejs/issues/events{/number}","events_url":"https://api.github.com/repos/elasticio/sailor-nodejs/events","assignees_url":"https://api.github.com/repos/elasticio/sailor-nodejs/assignees{/user}","branches_url":"https://api.github.com/repos/elasticio/sailor-nodejs/branches{/branch}","tags_url":"https://api.github.com/repos/elasticio/sailor-nodejs/tags","blobs_url":"https://api.github.com/repos/elasticio/sailor-nodejs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elasticio/sailor-nodejs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elasticio/sailor-nodejs/git/refs{/sha}","trees_url":"https://api.github.com/repos/elasticio/sailor-nodejs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elasticio/sailor-nodejs/statuses/{sha}","languages_url":"https://api.github.com/repos/elasticio/sailor-nodejs/languages","stargazers_url":"https://api.github.com/repos/elasticio/sailor-nodejs/stargazers","contributors_url":"https://api.github.com/repos/elasticio/sailor-nodejs/contributors","subscribers_url":"https://api.github.com/repos/elasticio/sailor-nodejs/subscribers","subscription_url":"https://api.github.com/repos/elasticio/sailor-nodejs/subscription","commits_url":"https://api.github.com/repos/elasticio/sailor-nodejs/commits{/sha}","git_commits_url":"https://api.github.com/repos/elasticio/sailor-nodejs/git/commits{/sha}","comments_url":"https://api.github.com/repos/elasticio/sailor-nodejs/comments{/number}","issue_comment_url":"https://api.github.com/repos/elasticio/sailor-nodejs/issues/comments{/number}","contents_url":"https://api.github.com/repos/elasticio/sailor-nodejs/contents/{+path}","compare_url":"https://api.github.com/repos/elasticio/sailor-nodejs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elasticio/sailor-nodejs/merges","archive_url":"https://api.github.com/repos/elasticio/sailor-nodejs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elasticio/sailor-nodejs/downloads","issues_url":"https://api.github.com/repos/elasticio/sailor-nodejs/issues{/number}","pulls_url":"https://api.github.com/repos/elasticio/sailor-nodejs/pulls{/number}","milestones_url":"https://api.github.com/repos/elasticio/sailor-nodejs/milestones{/number}","notifications_url":"https://api.github.com/repos/elasticio/sailor-nodejs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elasticio/sailor-nodejs/labels{/name}","releases_url":"https://api.github.com/repos/elasticio/sailor-nodejs/releases{/id}","created_at":"2015-04-23T16:30:34Z","updated_at":"2015-04-29T10:55:30Z","pushed_at":"2015-04-29T10:55:31Z","git_url":"git://github.com/elasticio/sailor-nodejs.git","ssh_url":"git@github.com:elasticio/sailor-nodejs.git","clone_url":"https://github.com/elasticio/sailor-nodejs.git","svn_url":"https://github.com/elasticio/sailor-nodejs","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"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":"elasticio:production","ref":"production","sha":"47ff33d03aa67fd5a0627277fbbe10eaafb6cc29","user":{"login":"elasticio","id":1560253,"avatar_url":"https://avatars.githubusercontent.com/u/1560253?v=3","gravatar_id":"","url":"https://api.github.com/users/elasticio","html_url":"https://github.com/elasticio","followers_url":"https://api.github.com/users/elasticio/followers","following_url":"https://api.github.com/users/elasticio/following{/other_user}","gists_url":"https://api.github.com/users/elasticio/gists{/gist_id}","starred_url":"https://api.github.com/users/elasticio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elasticio/subscriptions","organizations_url":"https://api.github.com/users/elasticio/orgs","repos_url":"https://api.github.com/users/elasticio/repos","events_url":"https://api.github.com/users/elasticio/events{/privacy}","received_events_url":"https://api.github.com/users/elasticio/received_events","type":"Organization","site_admin":false},"repo":{"id":34468171,"name":"sailor-nodejs","full_name":"elasticio/sailor-nodejs","owner":{"login":"elasticio","id":1560253,"avatar_url":"https://avatars.githubusercontent.com/u/1560253?v=3","gravatar_id":"","url":"https://api.github.com/users/elasticio","html_url":"https://github.com/elasticio","followers_url":"https://api.github.com/users/elasticio/followers","following_url":"https://api.github.com/users/elasticio/following{/other_user}","gists_url":"https://api.github.com/users/elasticio/gists{/gist_id}","starred_url":"https://api.github.com/users/elasticio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elasticio/subscriptions","organizations_url":"https://api.github.com/users/elasticio/orgs","repos_url":"https://api.github.com/users/elasticio/repos","events_url":"https://api.github.com/users/elasticio/events{/privacy}","received_events_url":"https://api.github.com/users/elasticio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elasticio/sailor-nodejs","description":"The official elastic.io library for bootstrapping and executing for Node.js connectors.","fork":false,"url":"https://api.github.com/repos/elasticio/sailor-nodejs","forks_url":"https://api.github.com/repos/elasticio/sailor-nodejs/forks","keys_url":"https://api.github.com/repos/elasticio/sailor-nodejs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elasticio/sailor-nodejs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elasticio/sailor-nodejs/teams","hooks_url":"https://api.github.com/repos/elasticio/sailor-nodejs/hooks","issue_events_url":"https://api.github.com/repos/elasticio/sailor-nodejs/issues/events{/number}","events_url":"https://api.github.com/repos/elasticio/sailor-nodejs/events","assignees_url":"https://api.github.com/repos/elasticio/sailor-nodejs/assignees{/user}","branches_url":"https://api.github.com/repos/elasticio/sailor-nodejs/branches{/branch}","tags_url":"https://api.github.com/repos/elasticio/sailor-nodejs/tags","blobs_url":"https://api.github.com/repos/elasticio/sailor-nodejs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elasticio/sailor-nodejs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elasticio/sailor-nodejs/git/refs{/sha}","trees_url":"https://api.github.com/repos/elasticio/sailor-nodejs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elasticio/sailor-nodejs/statuses/{sha}","languages_url":"https://api.github.com/repos/elasticio/sailor-nodejs/languages","stargazers_url":"https://api.github.com/repos/elasticio/sailor-nodejs/stargazers","contributors_url":"https://api.github.com/repos/elasticio/sailor-nodejs/contributors","subscribers_url":"https://api.github.com/repos/elasticio/sailor-nodejs/subscribers","subscription_url":"https://api.github.com/repos/elasticio/sailor-nodejs/subscription","commits_url":"https://api.github.com/repos/elasticio/sailor-nodejs/commits{/sha}","git_commits_url":"https://api.github.com/repos/elasticio/sailor-nodejs/git/commits{/sha}","comments_url":"https://api.github.com/repos/elasticio/sailor-nodejs/comments{/number}","issue_comment_url":"https://api.github.com/repos/elasticio/sailor-nodejs/issues/comments{/number}","contents_url":"https://api.github.com/repos/elasticio/sailor-nodejs/contents/{+path}","compare_url":"https://api.github.com/repos/elasticio/sailor-nodejs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elasticio/sailor-nodejs/merges","archive_url":"https://api.github.com/repos/elasticio/sailor-nodejs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elasticio/sailor-nodejs/downloads","issues_url":"https://api.github.com/repos/elasticio/sailor-nodejs/issues{/number}","pulls_url":"https://api.github.com/repos/elasticio/sailor-nodejs/pulls{/number}","milestones_url":"https://api.github.com/repos/elasticio/sailor-nodejs/milestones{/number}","notifications_url":"https://api.github.com/repos/elasticio/sailor-nodejs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elasticio/sailor-nodejs/labels{/name}","releases_url":"https://api.github.com/repos/elasticio/sailor-nodejs/releases{/id}","created_at":"2015-04-23T16:30:34Z","updated_at":"2015-04-29T10:55:30Z","pushed_at":"2015-04-29T10:55:31Z","git_url":"git://github.com/elasticio/sailor-nodejs.git","ssh_url":"git@github.com:elasticio/sailor-nodejs.git","clone_url":"https://github.com/elasticio/sailor-nodejs.git","svn_url":"https://github.com/elasticio/sailor-nodejs","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"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/elasticio/sailor-nodejs/pulls/1"},"html":{"href":"https://github.com/elasticio/sailor-nodejs/pull/1"},"issue":{"href":"https://api.github.com/repos/elasticio/sailor-nodejs/issues/1"},"comments":{"href":"https://api.github.com/repos/elasticio/sailor-nodejs/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/elasticio/sailor-nodejs/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/elasticio/sailor-nodejs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elasticio/sailor-nodejs/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/elasticio/sailor-nodejs/statuses/d6b20ffb662b8a5c9780f603780eaab52cbe8005"}}}}