add sidekiq worker, update endpoint
This commit is contained in:
parent
7e9c30896e
commit
39bd25cc3b
1
Procfile
1
Procfile
|
@ -1,2 +1,3 @@
|
|||
web: bundle exec ./script/server
|
||||
console: bundle exec ./script/console
|
||||
sidekiq: bundle exec sidekiq -c 5 -r ./lib/travis/sidekiq.rb -q build_cancellations
|
||||
|
|
|
@ -37,7 +37,9 @@ class Travis::Api::App
|
|||
status 422
|
||||
respond_with json
|
||||
else
|
||||
service.run
|
||||
#service.run
|
||||
#check syntax of line below
|
||||
Travis::Sidekiq::BuildCancellation.perform_async(params.merge(source: 'api'))
|
||||
|
||||
Metriks.meter("api.request.cancel_build.success").mark
|
||||
status 204
|
||||
|
|
29
lib/travis/api/workers/build_cancellation.rb
Normal file
29
lib/travis/api/workers/build_cancellation.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
require 'sidekiq/worker'
|
||||
require 'multi_json'
|
||||
|
||||
module Travis
|
||||
module Sidekiq
|
||||
class BuildCancellation
|
||||
class ProcessingError < StandardError; end
|
||||
|
||||
include ::Sidekiq::Worker
|
||||
# do we need to name the queue here? we didn't do this in Admin. We passed this info in the procfile
|
||||
sidekiq_options queue: build_cancellations
|
||||
|
||||
attr_accessor :data
|
||||
|
||||
def perform(data)
|
||||
@data = data
|
||||
if payload
|
||||
service.run
|
||||
else
|
||||
Travis.logger.warn("The #{type} payload was empty and could not be processed")
|
||||
end
|
||||
end
|
||||
|
||||
def service
|
||||
@service ||= Travis.service(:cancel_build, data)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
7
lib/travis/sidekiq.rb
Normal file
7
lib/travis/sidekiq.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
$: << './lib'
|
||||
require 'travis/core'
|
||||
require 'travis/app/workers/build_cancellation'
|
||||
|
||||
Sidekiq.configure_server do |config|
|
||||
config.redis = Travis.config.redis.merge(namespace: Travis.config.sidekiq.namespace)
|
||||
end
|
Loading…
Reference in New Issue
Block a user