{"action":"created","comment":{"url":"https://api.github.com/repos/phstc/shoryuken/pulls/comments/92687914","pull_request_review_id":13206343,"id":92687914,"diff_hunk":"@@ -102,5 +123,94 @@ def queue_weight(queues, queue)\n         queues.count { |q| q == queue }\n       end\n     end\n+\n+    class StrictPriority < BaseStrategy\n+\n+      def initialize(queues)\n+        # Mapping of queues to priority values\n+        @queue_priorities = queues\n+          .each_with_object(Hash.new(0)) { |queue, h| h[queue] += 1 }\n+\n+        # Priority ordering of the queues\n+        @queue_order = @queue_priorities\n+          .to_a\n+          .sort_by { |queue, priority| -priority }\n+          .map(&:first)\n+\n+        # Pause status of the queues\n+        @queue_status = @queue_order\n+          .each_with_object({}) { |queue, h| h[queue] = [true, nil] }\n+\n+        # Most recently used queue\n+        @current_queue = nil\n+      end\n+\n+      def next_queue\n+        unpause_queues\n+        @current_queue = next_active_queue\n+        return nil if @current_queue.nil?\n+        QueueConfiguration.new(@current_queue, {})\n+      end\n+\n+      def messages_found(queue, messages_found)\n+        if messages_found == 0\n+          # If no messages are found, we pause a given queue\n+          pause(queue) \n+        else\n+          # Reset the current queue when messages found to cause priorities to re-run\n+          @current_queue = nil\n+        end\n+      end\n+\n+      def active_queues\n+        @queue_status\n+          .select { |_, status| status.first }\n+          .map { |queue, _| [queue, @queue_priorities[queue]] }\n+      end\n+\n+      private\n+\n+      def next_active_queue\n+        return nil unless @queue_order.length > 0\n+\n+        start = @current_queue.nil? ? 0 : @queue_order.index(@current_queue) + 1\n+        i = 0\n+\n+        # Loop through the queue order from the current queue until we find a\n+        # queue that is next in line and is not paused\n+        while true","path":"lib/shoryuken/polling.rb","position":136,"original_position":136,"commit_id":"05b467b6dccaea130d8d9629d6dd65e93a618e1b","original_commit_id":"05b467b6dccaea130d8d9629d6dd65e93a618e1b","user":{"login":"mariokostelac","id":1917451,"avatar_url":"https://avatars.githubusercontent.com/u/1917451?v=3","gravatar_id":"","url":"https://api.github.com/users/mariokostelac","html_url":"https://github.com/mariokostelac","followers_url":"https://api.github.com/users/mariokostelac/followers","following_url":"https://api.github.com/users/mariokostelac/following{/other_user}","gists_url":"https://api.github.com/users/mariokostelac/gists{/gist_id}","starred_url":"https://api.github.com/users/mariokostelac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mariokostelac/subscriptions","organizations_url":"https://api.github.com/users/mariokostelac/orgs","repos_url":"https://api.github.com/users/mariokostelac/repos","events_url":"https://api.github.com/users/mariokostelac/events{/privacy}","received_events_url":"https://api.github.com/users/mariokostelac/received_events","type":"User","site_admin":false},"body":"Can we use a for loop? This external bookkeeping of variable i looks ugly.","created_at":"2016-12-15T19:57:09Z","updated_at":"2016-12-15T20:01:55Z","html_url":"https://github.com/phstc/shoryuken/pull/288#discussion_r92687914","pull_request_url":"https://api.github.com/repos/phstc/shoryuken/pulls/288","_links":{"self":{"href":"https://api.github.com/repos/phstc/shoryuken/pulls/comments/92687914"},"html":{"href":"https://github.com/phstc/shoryuken/pull/288#discussion_r92687914"},"pull_request":{"href":"https://api.github.com/repos/phstc/shoryuken/pulls/288"}}},"pull_request":{"url":"https://api.github.com/repos/phstc/shoryuken/pulls/288","id":97861215,"html_url":"https://github.com/phstc/shoryuken/pull/288","diff_url":"https://github.com/phstc/shoryuken/pull/288.diff","patch_url":"https://github.com/phstc/shoryuken/pull/288.patch","issue_url":"https://api.github.com/repos/phstc/shoryuken/issues/288","number":288,"state":"open","locked":false,"title":"Strict priority polling w/ backmerge","user":{"login":"atyndall","id":1833303,"avatar_url":"https://avatars.githubusercontent.com/u/1833303?v=3","gravatar_id":"","url":"https://api.github.com/users/atyndall","html_url":"https://github.com/atyndall","followers_url":"https://api.github.com/users/atyndall/followers","following_url":"https://api.github.com/users/atyndall/following{/other_user}","gists_url":"https://api.github.com/users/atyndall/gists{/gist_id}","starred_url":"https://api.github.com/users/atyndall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atyndall/subscriptions","organizations_url":"https://api.github.com/users/atyndall/orgs","repos_url":"https://api.github.com/users/atyndall/repos","events_url":"https://api.github.com/users/atyndall/events{/privacy}","received_events_url":"https://api.github.com/users/atyndall/received_events","type":"User","site_admin":false},"body":"@phstc This is the strict priority polling implementation from #263 with master backmerged, it didn't make it when you closed #263 in favour of #284.","created_at":"2016-12-13T23:56:18Z","updated_at":"2016-12-15T20:01:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"40f428d7b38bbd5cd9b1db38a113692cb24ae53d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/phstc/shoryuken/pulls/288/commits","review_comments_url":"https://api.github.com/repos/phstc/shoryuken/pulls/288/comments","review_comment_url":"https://api.github.com/repos/phstc/shoryuken/pulls/comments{/number}","comments_url":"https://api.github.com/repos/phstc/shoryuken/issues/288/comments","statuses_url":"https://api.github.com/repos/phstc/shoryuken/statuses/05b467b6dccaea130d8d9629d6dd65e93a618e1b","head":{"label":"appbot:strict_priority_polling","ref":"strict_priority_polling","sha":"05b467b6dccaea130d8d9629d6dd65e93a618e1b","user":{"login":"appbot","id":7652956,"avatar_url":"https://avatars.githubusercontent.com/u/7652956?v=3","gravatar_id":"","url":"https://api.github.com/users/appbot","html_url":"https://github.com/appbot","followers_url":"https://api.github.com/users/appbot/followers","following_url":"https://api.github.com/users/appbot/following{/other_user}","gists_url":"https://api.github.com/users/appbot/gists{/gist_id}","starred_url":"https://api.github.com/users/appbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/appbot/subscriptions","organizations_url":"https://api.github.com/users/appbot/orgs","repos_url":"https://api.github.com/users/appbot/repos","events_url":"https://api.github.com/users/appbot/events{/privacy}","received_events_url":"https://api.github.com/users/appbot/received_events","type":"Organization","site_admin":false},"repo":{"id":71516302,"name":"shoryuken","full_name":"appbot/shoryuken","owner":{"login":"appbot","id":7652956,"avatar_url":"https://avatars.githubusercontent.com/u/7652956?v=3","gravatar_id":"","url":"https://api.github.com/users/appbot","html_url":"https://github.com/appbot","followers_url":"https://api.github.com/users/appbot/followers","following_url":"https://api.github.com/users/appbot/following{/other_user}","gists_url":"https://api.github.com/users/appbot/gists{/gist_id}","starred_url":"https://api.github.com/users/appbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/appbot/subscriptions","organizations_url":"https://api.github.com/users/appbot/orgs","repos_url":"https://api.github.com/users/appbot/repos","events_url":"https://api.github.com/users/appbot/events{/privacy}","received_events_url":"https://api.github.com/users/appbot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/appbot/shoryuken","description":"A super efficient AWS SQS thread based message processor for Ruby","fork":true,"url":"https://api.github.com/repos/appbot/shoryuken","forks_url":"https://api.github.com/repos/appbot/shoryuken/forks","keys_url":"https://api.github.com/repos/appbot/shoryuken/keys{/key_id}","collaborators_url":"https://api.github.com/repos/appbot/shoryuken/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/appbot/shoryuken/teams","hooks_url":"https://api.github.com/repos/appbot/shoryuken/hooks","issue_events_url":"https://api.github.com/repos/appbot/shoryuken/issues/events{/number}","events_url":"https://api.github.com/repos/appbot/shoryuken/events","assignees_url":"https://api.github.com/repos/appbot/shoryuken/assignees{/user}","branches_url":"https://api.github.com/repos/appbot/shoryuken/branches{/branch}","tags_url":"https://api.github.com/repos/appbot/shoryuken/tags","blobs_url":"https://api.github.com/repos/appbot/shoryuken/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/appbot/shoryuken/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/appbot/shoryuken/git/refs{/sha}","trees_url":"https://api.github.com/repos/appbot/shoryuken/git/trees{/sha}","statuses_url":"https://api.github.com/repos/appbot/shoryuken/statuses/{sha}","languages_url":"https://api.github.com/repos/appbot/shoryuken/languages","stargazers_url":"https://api.github.com/repos/appbot/shoryuken/stargazers","contributors_url":"https://api.github.com/repos/appbot/shoryuken/contributors","subscribers_url":"https://api.github.com/repos/appbot/shoryuken/subscribers","subscription_url":"https://api.github.com/repos/appbot/shoryuken/subscription","commits_url":"https://api.github.com/repos/appbot/shoryuken/commits{/sha}","git_commits_url":"https://api.github.com/repos/appbot/shoryuken/git/commits{/sha}","comments_url":"https://api.github.com/repos/appbot/shoryuken/comments{/number}","issue_comment_url":"https://api.github.com/repos/appbot/shoryuken/issues/comments{/number}","contents_url":"https://api.github.com/repos/appbot/shoryuken/contents/{+path}","compare_url":"https://api.github.com/repos/appbot/shoryuken/compare/{base}...{head}","merges_url":"https://api.github.com/repos/appbot/shoryuken/merges","archive_url":"https://api.github.com/repos/appbot/shoryuken/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/appbot/shoryuken/downloads","issues_url":"https://api.github.com/repos/appbot/shoryuken/issues{/number}","pulls_url":"https://api.github.com/repos/appbot/shoryuken/pulls{/number}","milestones_url":"https://api.github.com/repos/appbot/shoryuken/milestones{/number}","notifications_url":"https://api.github.com/repos/appbot/shoryuken/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/appbot/shoryuken/labels{/name}","releases_url":"https://api.github.com/repos/appbot/shoryuken/releases{/id}","deployments_url":"https://api.github.com/repos/appbot/shoryuken/deployments","created_at":"2016-10-21T00:49:47Z","updated_at":"2016-10-21T00:49:48Z","pushed_at":"2016-12-14T23:21:07Z","git_url":"git://github.com/appbot/shoryuken.git","ssh_url":"git@github.com:appbot/shoryuken.git","clone_url":"https://github.com/appbot/shoryuken.git","svn_url":"https://github.com/appbot/shoryuken","homepage":"","size":505,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"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":"phstc:master","ref":"master","sha":"ebeb81da57f68a680a065c57739465b3c3d32888","user":{"login":"phstc","id":105652,"avatar_url":"https://avatars.githubusercontent.com/u/105652?v=3","gravatar_id":"","url":"https://api.github.com/users/phstc","html_url":"https://github.com/phstc","followers_url":"https://api.github.com/users/phstc/followers","following_url":"https://api.github.com/users/phstc/following{/other_user}","gists_url":"https://api.github.com/users/phstc/gists{/gist_id}","starred_url":"https://api.github.com/users/phstc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phstc/subscriptions","organizations_url":"https://api.github.com/users/phstc/orgs","repos_url":"https://api.github.com/users/phstc/repos","events_url":"https://api.github.com/users/phstc/events{/privacy}","received_events_url":"https://api.github.com/users/phstc/received_events","type":"User","site_admin":false},"repo":{"id":23578850,"name":"shoryuken","full_name":"phstc/shoryuken","owner":{"login":"phstc","id":105652,"avatar_url":"https://avatars.githubusercontent.com/u/105652?v=3","gravatar_id":"","url":"https://api.github.com/users/phstc","html_url":"https://github.com/phstc","followers_url":"https://api.github.com/users/phstc/followers","following_url":"https://api.github.com/users/phstc/following{/other_user}","gists_url":"https://api.github.com/users/phstc/gists{/gist_id}","starred_url":"https://api.github.com/users/phstc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phstc/subscriptions","organizations_url":"https://api.github.com/users/phstc/orgs","repos_url":"https://api.github.com/users/phstc/repos","events_url":"https://api.github.com/users/phstc/events{/privacy}","received_events_url":"https://api.github.com/users/phstc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/phstc/shoryuken","description":"A super efficient AWS SQS thread based message processor for Ruby","fork":false,"url":"https://api.github.com/repos/phstc/shoryuken","forks_url":"https://api.github.com/repos/phstc/shoryuken/forks","keys_url":"https://api.github.com/repos/phstc/shoryuken/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phstc/shoryuken/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phstc/shoryuken/teams","hooks_url":"https://api.github.com/repos/phstc/shoryuken/hooks","issue_events_url":"https://api.github.com/repos/phstc/shoryuken/issues/events{/number}","events_url":"https://api.github.com/repos/phstc/shoryuken/events","assignees_url":"https://api.github.com/repos/phstc/shoryuken/assignees{/user}","branches_url":"https://api.github.com/repos/phstc/shoryuken/branches{/branch}","tags_url":"https://api.github.com/repos/phstc/shoryuken/tags","blobs_url":"https://api.github.com/repos/phstc/shoryuken/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phstc/shoryuken/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phstc/shoryuken/git/refs{/sha}","trees_url":"https://api.github.com/repos/phstc/shoryuken/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phstc/shoryuken/statuses/{sha}","languages_url":"https://api.github.com/repos/phstc/shoryuken/languages","stargazers_url":"https://api.github.com/repos/phstc/shoryuken/stargazers","contributors_url":"https://api.github.com/repos/phstc/shoryuken/contributors","subscribers_url":"https://api.github.com/repos/phstc/shoryuken/subscribers","subscription_url":"https://api.github.com/repos/phstc/shoryuken/subscription","commits_url":"https://api.github.com/repos/phstc/shoryuken/commits{/sha}","git_commits_url":"https://api.github.com/repos/phstc/shoryuken/git/commits{/sha}","comments_url":"https://api.github.com/repos/phstc/shoryuken/comments{/number}","issue_comment_url":"https://api.github.com/repos/phstc/shoryuken/issues/comments{/number}","contents_url":"https://api.github.com/repos/phstc/shoryuken/contents/{+path}","compare_url":"https://api.github.com/repos/phstc/shoryuken/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phstc/shoryuken/merges","archive_url":"https://api.github.com/repos/phstc/shoryuken/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phstc/shoryuken/downloads","issues_url":"https://api.github.com/repos/phstc/shoryuken/issues{/number}","pulls_url":"https://api.github.com/repos/phstc/shoryuken/pulls{/number}","milestones_url":"https://api.github.com/repos/phstc/shoryuken/milestones{/number}","notifications_url":"https://api.github.com/repos/phstc/shoryuken/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phstc/shoryuken/labels{/name}","releases_url":"https://api.github.com/repos/phstc/shoryuken/releases{/id}","deployments_url":"https://api.github.com/repos/phstc/shoryuken/deployments","created_at":"2014-09-02T13:04:10Z","updated_at":"2016-12-15T02:10:05Z","pushed_at":"2016-12-14T23:21:08Z","git_url":"git://github.com/phstc/shoryuken.git","ssh_url":"git@github.com:phstc/shoryuken.git","clone_url":"https://github.com/phstc/shoryuken.git","svn_url":"https://github.com/phstc/shoryuken","homepage":"","size":506,"stargazers_count":865,"watchers_count":865,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":126,"mirror_url":null,"open_issues_count":9,"forks":126,"open_issues":9,"watchers":865,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/phstc/shoryuken/pulls/288"},"html":{"href":"https://github.com/phstc/shoryuken/pull/288"},"issue":{"href":"https://api.github.com/repos/phstc/shoryuken/issues/288"},"comments":{"href":"https://api.github.com/repos/phstc/shoryuken/issues/288/comments"},"review_comments":{"href":"https://api.github.com/repos/phstc/shoryuken/pulls/288/comments"},"review_comment":{"href":"https://api.github.com/repos/phstc/shoryuken/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/phstc/shoryuken/pulls/288/commits"},"statuses":{"href":"https://api.github.com/repos/phstc/shoryuken/statuses/05b467b6dccaea130d8d9629d6dd65e93a618e1b"}}}}
{"actor":{"display_login":"mariokostelac"}}