{"action":"created","comment":{"url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/pulls/comments/112684648","pull_request_review_id":34019882,"id":112684648,"diff_hunk":"@@ -0,0 +1,70 @@\n+import logging\n+\n+from tornado import gen\n+\n+\n+LOGGER = logging.getLogger(__name__)\n+\n+\n+class PublishingMixin(object):\n+    \"\"\"This mixin adds publishing messages to RabbitMQ. It uses a\n+    persistent connection and channel opened when the application\n+    start up and automatically reopened if closed by RabbitMQ\n+\n+    \"\"\"\n+    @property\n+    def app_id(self):\n+        \"\"\"Return a value to be used for the app_id AMQP message property.\n+\n+        :rtype: str\n+\n+        \"\"\"\n+        service = self.application.settings.get('service')\n+        version = self.application.settings.get('version')\n+        return self.generate_app_id(service, version)\n+\n+    @staticmethod\n+    def generate_app_id(service, version):\n+        return '{}/{}'.format(service, version)\n+\n+    @gen.coroutine\n+    def publish_amqp_message(self,\n+                             exchange,\n+                             routing_key,\n+                             body,\n+                             properties=None,\n+                             mandatory=False):\n+        \"\"\"Publish the message to RabbitMQ\n+\n+        Expects Correlation ID to be available via self.correlation_id,\n+        default value will be None if not set.\n+        The ``sprockets.mixins.correlation`` plugin provides this.\n+\n+        :param str exchange: The exchange to publish the message to\n+        :param str routing_key: The routing key to publish the message with\n+        :param bytes body: The message body to send\n+        :param dict properties: An optional dict of additional properties\n+                                to append. Will not override mandatory\n+                                properties:\n+                                app_id, correlation_id, message_id, timestamp\n+        :param bool mandatory: Whether to instruct the server to return an\n+                               unqueueable message\n+                               http://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.publish.mandatory\n+\n+        \"\"\"\n+        yield self.application.amqp.publish(\n+            exchange,\n+            routing_key,\n+            body,\n+            self.app_id,\n+            getattr(self, 'correlation_id'),\n+            properties,\n+            mandatory\n+        )\n+\n+    @gen.coroutine\n+    def amqp_publish(self, exchange, routing_key, body, properties):","path":"sprockets/mixins/amqp/mixins.py","position":66,"original_position":66,"commit_id":"3bcfe439f5107728c5188c5b7a27a09daf2aa279","original_commit_id":"3bcfe439f5107728c5188c5b7a27a09daf2aa279","user":{"login":"ibnpaul","id":1821224,"avatar_url":"https://avatars2.githubusercontent.com/u/1821224?v=3","gravatar_id":"","url":"https://api.github.com/users/ibnpaul","html_url":"https://github.com/ibnpaul","followers_url":"https://api.github.com/users/ibnpaul/followers","following_url":"https://api.github.com/users/ibnpaul/following{/other_user}","gists_url":"https://api.github.com/users/ibnpaul/gists{/gist_id}","starred_url":"https://api.github.com/users/ibnpaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibnpaul/subscriptions","organizations_url":"https://api.github.com/users/ibnpaul/orgs","repos_url":"https://api.github.com/users/ibnpaul/repos","events_url":"https://api.github.com/users/ibnpaul/events{/privacy}","received_events_url":"https://api.github.com/users/ibnpaul/received_events","type":"User","site_admin":false},"body":"fixed","created_at":"2017-04-21T13:17:39Z","updated_at":"2017-04-21T13:17:40Z","html_url":"https://github.com/sprockets/sprockets.mixins.amqp/pull/9#discussion_r112684648","pull_request_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/pulls/comments/112684648"},"html":{"href":"https://github.com/sprockets/sprockets.mixins.amqp/pull/9#discussion_r112684648"},"pull_request":{"href":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/pulls/9","id":116560039,"html_url":"https://github.com/sprockets/sprockets.mixins.amqp/pull/9","diff_url":"https://github.com/sprockets/sprockets.mixins.amqp/pull/9.diff","patch_url":"https://github.com/sprockets/sprockets.mixins.amqp/pull/9.patch","issue_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/issues/9","number":9,"state":"open","locked":false,"title":"Replace AMQP publisher internals with latest internal version","user":{"login":"ibnpaul","id":1821224,"avatar_url":"https://avatars2.githubusercontent.com/u/1821224?v=3","gravatar_id":"","url":"https://api.github.com/users/ibnpaul","html_url":"https://github.com/ibnpaul","followers_url":"https://api.github.com/users/ibnpaul/followers","following_url":"https://api.github.com/users/ibnpaul/following{/other_user}","gists_url":"https://api.github.com/users/ibnpaul/gists{/gist_id}","starred_url":"https://api.github.com/users/ibnpaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibnpaul/subscriptions","organizations_url":"https://api.github.com/users/ibnpaul/orgs","repos_url":"https://api.github.com/users/ibnpaul/repos","events_url":"https://api.github.com/users/ibnpaul/events{/privacy}","received_events_url":"https://api.github.com/users/ibnpaul/received_events","type":"User","site_admin":false},"body":"This takes the latest internal AMQP publisher and refactors the connection-handling portion of it into this sprocket.\r\n\r\nThe version has been bumped to 2.0.0 as there are contract changes in the sprocket.\r\n","created_at":"2017-04-19T14:21:49Z","updated_at":"2017-04-21T13:17:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"084614fa36d63fb46f85984a3ed0cd6548ae0a50","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/pulls/9/commits","review_comments_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/pulls/9/comments","review_comment_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/issues/9/comments","statuses_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/statuses/3bcfe439f5107728c5188c5b7a27a09daf2aa279","head":{"label":"ibnpaul:amqp-refactor","ref":"amqp-refactor","sha":"3bcfe439f5107728c5188c5b7a27a09daf2aa279","user":{"login":"ibnpaul","id":1821224,"avatar_url":"https://avatars2.githubusercontent.com/u/1821224?v=3","gravatar_id":"","url":"https://api.github.com/users/ibnpaul","html_url":"https://github.com/ibnpaul","followers_url":"https://api.github.com/users/ibnpaul/followers","following_url":"https://api.github.com/users/ibnpaul/following{/other_user}","gists_url":"https://api.github.com/users/ibnpaul/gists{/gist_id}","starred_url":"https://api.github.com/users/ibnpaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibnpaul/subscriptions","organizations_url":"https://api.github.com/users/ibnpaul/orgs","repos_url":"https://api.github.com/users/ibnpaul/repos","events_url":"https://api.github.com/users/ibnpaul/events{/privacy}","received_events_url":"https://api.github.com/users/ibnpaul/received_events","type":"User","site_admin":false},"repo":{"id":88095069,"name":"sprockets.mixins.amqp","full_name":"ibnpaul/sprockets.mixins.amqp","owner":{"login":"ibnpaul","id":1821224,"avatar_url":"https://avatars2.githubusercontent.com/u/1821224?v=3","gravatar_id":"","url":"https://api.github.com/users/ibnpaul","html_url":"https://github.com/ibnpaul","followers_url":"https://api.github.com/users/ibnpaul/followers","following_url":"https://api.github.com/users/ibnpaul/following{/other_user}","gists_url":"https://api.github.com/users/ibnpaul/gists{/gist_id}","starred_url":"https://api.github.com/users/ibnpaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibnpaul/subscriptions","organizations_url":"https://api.github.com/users/ibnpaul/orgs","repos_url":"https://api.github.com/users/ibnpaul/repos","events_url":"https://api.github.com/users/ibnpaul/events{/privacy}","received_events_url":"https://api.github.com/users/ibnpaul/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ibnpaul/sprockets.mixins.amqp","description":"Worker controller and base classes","fork":true,"url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp","forks_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/forks","keys_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/teams","hooks_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/hooks","issue_events_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/issues/events{/number}","events_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/events","assignees_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/assignees{/user}","branches_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/branches{/branch}","tags_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/tags","blobs_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/git/refs{/sha}","trees_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/statuses/{sha}","languages_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/languages","stargazers_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/stargazers","contributors_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/contributors","subscribers_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/subscribers","subscription_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/subscription","commits_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/commits{/sha}","git_commits_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/git/commits{/sha}","comments_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/comments{/number}","issue_comment_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/issues/comments{/number}","contents_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/contents/{+path}","compare_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/merges","archive_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/downloads","issues_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/issues{/number}","pulls_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/pulls{/number}","milestones_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/milestones{/number}","notifications_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/labels{/name}","releases_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/releases{/id}","deployments_url":"https://api.github.com/repos/ibnpaul/sprockets.mixins.amqp/deployments","created_at":"2017-04-12T20:50:41Z","updated_at":"2017-04-12T20:50:42Z","pushed_at":"2017-04-20T21:06:18Z","git_url":"git://github.com/ibnpaul/sprockets.mixins.amqp.git","ssh_url":"git@github.com:ibnpaul/sprockets.mixins.amqp.git","clone_url":"https://github.com/ibnpaul/sprockets.mixins.amqp.git","svn_url":"https://github.com/ibnpaul/sprockets.mixins.amqp","homepage":null,"size":56,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sprockets:master","ref":"master","sha":"eff0c8a9fe2631d3bba24130601e7aeaa5d66680","user":{"login":"sprockets","id":8236802,"avatar_url":"https://avatars1.githubusercontent.com/u/8236802?v=3","gravatar_id":"","url":"https://api.github.com/users/sprockets","html_url":"https://github.com/sprockets","followers_url":"https://api.github.com/users/sprockets/followers","following_url":"https://api.github.com/users/sprockets/following{/other_user}","gists_url":"https://api.github.com/users/sprockets/gists{/gist_id}","starred_url":"https://api.github.com/users/sprockets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sprockets/subscriptions","organizations_url":"https://api.github.com/users/sprockets/orgs","repos_url":"https://api.github.com/users/sprockets/repos","events_url":"https://api.github.com/users/sprockets/events{/privacy}","received_events_url":"https://api.github.com/users/sprockets/received_events","type":"Organization","site_admin":false},"repo":{"id":23115922,"name":"sprockets.mixins.amqp","full_name":"sprockets/sprockets.mixins.amqp","owner":{"login":"sprockets","id":8236802,"avatar_url":"https://avatars1.githubusercontent.com/u/8236802?v=3","gravatar_id":"","url":"https://api.github.com/users/sprockets","html_url":"https://github.com/sprockets","followers_url":"https://api.github.com/users/sprockets/followers","following_url":"https://api.github.com/users/sprockets/following{/other_user}","gists_url":"https://api.github.com/users/sprockets/gists{/gist_id}","starred_url":"https://api.github.com/users/sprockets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sprockets/subscriptions","organizations_url":"https://api.github.com/users/sprockets/orgs","repos_url":"https://api.github.com/users/sprockets/repos","events_url":"https://api.github.com/users/sprockets/events{/privacy}","received_events_url":"https://api.github.com/users/sprockets/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sprockets/sprockets.mixins.amqp","description":"Worker controller and base classes","fork":false,"url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp","forks_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/forks","keys_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/teams","hooks_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/hooks","issue_events_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/issues/events{/number}","events_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/events","assignees_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/assignees{/user}","branches_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/branches{/branch}","tags_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/tags","blobs_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/git/refs{/sha}","trees_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/statuses/{sha}","languages_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/languages","stargazers_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/stargazers","contributors_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/contributors","subscribers_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/subscribers","subscription_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/subscription","commits_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/commits{/sha}","git_commits_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/git/commits{/sha}","comments_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/comments{/number}","issue_comment_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/issues/comments{/number}","contents_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/contents/{+path}","compare_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/merges","archive_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/downloads","issues_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/issues{/number}","pulls_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/pulls{/number}","milestones_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/milestones{/number}","notifications_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/labels{/name}","releases_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/releases{/id}","deployments_url":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/deployments","created_at":"2014-08-19T15:45:42Z","updated_at":"2017-02-28T16:23:18Z","pushed_at":"2017-04-20T21:06:19Z","git_url":"git://github.com/sprockets/sprockets.mixins.amqp.git","ssh_url":"git@github.com:sprockets/sprockets.mixins.amqp.git","clone_url":"https://github.com/sprockets/sprockets.mixins.amqp.git","svn_url":"https://github.com/sprockets/sprockets.mixins.amqp","homepage":null,"size":44,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/pulls/9"},"html":{"href":"https://github.com/sprockets/sprockets.mixins.amqp/pull/9"},"issue":{"href":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/issues/9"},"comments":{"href":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/sprockets/sprockets.mixins.amqp/statuses/3bcfe439f5107728c5188c5b7a27a09daf2aa279"}}}}
{"actor":{"display_login":"ibnpaul"}}