forked from houndci/hound
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://trello.com/c/adsxS8Sv/197-use-resque * Create JobQueue to abstract queue choice
- Loading branch information
1 parent
7a61c26
commit 95edf32
Showing
42 changed files
with
365 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb | ||
worker: bundle exec rake jobs:work | ||
resque: env TERM_CHILD=1 RESQUE_TERM_TIMEOUT=8 bundle exec rake resque:work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
App.factory 'User', ['$resource', ($resource) -> | ||
$resource '/user' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,12 @@ | ||
class RepoSyncsController < ApplicationController | ||
respond_to :json | ||
|
||
def index | ||
syncs = Delayed::Job.uncached do | ||
Delayed::Job.where(<<-SQL) | ||
handler like '%RepoSynchronizationJob%' | ||
and handler like '%user_id: #{current_user.id}%' | ||
and failed_at IS NULL | ||
SQL | ||
end | ||
|
||
respond_with syncs | ||
end | ||
|
||
def create | ||
sync_job = RepoSynchronizationJob.new(current_user.id, session[:github_token]) | ||
Delayed::Job.enqueue(sync_job) | ||
JobQueue.push( | ||
RepoSynchronizationJob, | ||
current_user.id, | ||
session[:github_token] | ||
) | ||
head 201 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class UsersController < ApplicationController | ||
respond_to :json | ||
|
||
def show | ||
respond_with current_user | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'resque' | ||
|
||
module Buildable | ||
def perform(payload_data) | ||
payload = Payload.new(payload_data) | ||
build_runner = BuildRunner.new(payload) | ||
build_runner.run | ||
rescue Resque::TermException | ||
Resque.enqueue(self, payload_data) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'octokit' | ||
|
||
class LargeBuildJob | ||
extend Retryable | ||
extend Buildable | ||
|
||
@queue = :low | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
class RepoSynchronizationJob < Struct.new(:user_id, :github_token) | ||
include Monitorable | ||
class RepoSynchronizationJob | ||
extend Retryable | ||
|
||
def perform | ||
@queue = :high | ||
|
||
def self.before_enqueue(user_id, github_token) | ||
user = User.find(user_id) | ||
user.update_attribute(:refreshing_repos, true) | ||
end | ||
|
||
def self.perform(user_id, github_token) | ||
user = User.find(user_id) | ||
synchronization = RepoSynchronization.new(user, github_token) | ||
synchronization.start | ||
user.update_attribute(:refreshing_repos, false) | ||
rescue Resque::TermException | ||
Resque.enqueue(self, user_id, github_token) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'resque-retry' | ||
|
||
module Retryable | ||
extend Resque::Plugins::Retry | ||
|
||
@retry_limit = 10 | ||
@retry_delay = 120 | ||
@fatal_exceptions = [Octokit::NotFound, Octokit::Unauthorized] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'octokit' | ||
|
||
class SmallBuildJob | ||
extend Retryable | ||
extend Buildable | ||
|
||
@queue = :medium | ||
end |
Oops, something went wrong.