Remove push_matrix method, no need of it
This commit is contained in:
parent
29f80ab31b
commit
00bae7a945
|
@ -46,8 +46,8 @@ class Travis::Api::App
|
||||||
status 422
|
status 422
|
||||||
respond_with json
|
respond_with json
|
||||||
else
|
else
|
||||||
if service.respond_to?(:enqueue_to_hub)
|
if service.respond_to?(:push)
|
||||||
service.enqueue_to_hub
|
service.push
|
||||||
else
|
else
|
||||||
Travis::Sidekiq::BuildCancellation.perform_async(id: params[:id], user_id: current_user.id, source: 'api')
|
Travis::Sidekiq::BuildCancellation.perform_async(id: params[:id], user_id: current_user.id, source: 'api')
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,8 +53,8 @@ class Travis::Api::App
|
||||||
status 422
|
status 422
|
||||||
respond_with json
|
respond_with json
|
||||||
else
|
else
|
||||||
if service.respond_to?(:enqueue_to_hub)
|
if service.respond_to?(:push)
|
||||||
service.enqueue_to_hub
|
service.push
|
||||||
else
|
else
|
||||||
Travis::Sidekiq::JobCancellation.perform_async(id: params[:id], user_id: current_user.id, source: 'api')
|
Travis::Sidekiq::JobCancellation.perform_async(id: params[:id], user_id: current_user.id, source: 'api')
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,35 +20,17 @@ module Travis
|
||||||
messages
|
messages
|
||||||
end
|
end
|
||||||
|
|
||||||
def enqueue_to_hub
|
def push
|
||||||
# target may have been retrieved with a :join query, so we need to reset the readonly status
|
# target may have been retrieved with a :join query, so we need to reset the readonly status
|
||||||
if can_cancel?
|
if can_cancel?
|
||||||
target.send(:instance_variable_set, :@readonly, false)
|
::Sidekiq::Client.push(
|
||||||
target.cancel!
|
'queue' => 'hub',
|
||||||
|
'class' => 'Travis::Hub::Sidekiq::Worker',
|
||||||
if type == :build
|
'args' => ["#{type}:cancel", @params]
|
||||||
push_matrix(@params)
|
)
|
||||||
else
|
|
||||||
push(@params, target)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def push_matrix(payload)
|
|
||||||
target.matrix.each do |job|
|
|
||||||
push(payload, job)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def push(payload, job)
|
|
||||||
Travis.logger.info("Publishing cancel_job message to worker.commands queue for Job##{job.id}")
|
|
||||||
::Sidekiq::Client.push(
|
|
||||||
'queue' => 'hub',
|
|
||||||
'class' => 'Travis::Hub::Sidekiq::Worker',
|
|
||||||
'args' => ["#{type}:cancel", payload]
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def type
|
def type
|
||||||
@type ||= @params[:build_id] ? :build : :job
|
@type ||= @params[:build_id] ? :build : :job
|
||||||
end
|
end
|
||||||
|
@ -70,7 +52,6 @@ module Travis
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -122,12 +122,12 @@ describe 'Builds' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'cancels the build' do
|
it 'cancels the build' do
|
||||||
::Sidekiq::Client.expects(:push).times(4)
|
::Sidekiq::Client.expects(:push)
|
||||||
post "/builds/#{build.id}/cancel", {}, headers
|
post "/builds/#{build.id}/cancel", {}, headers
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'responds with 204' do
|
it 'responds with 204' do
|
||||||
::Sidekiq::Client.expects(:push).times(4)
|
::Sidekiq::Client.expects(:push)
|
||||||
response = post "/builds/#{build.id}/cancel", {}, headers
|
response = post "/builds/#{build.id}/cancel", {}, headers
|
||||||
response.status.should == 204
|
response.status.should == 204
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user