Commit f59032e7 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'async-services' into 'master'

Async services

Fixes #1814

See merge request !1312
parents 2a494d99 0d5265bb
...@@ -390,14 +390,8 @@ class Project < ActiveRecord::Base ...@@ -390,14 +390,8 @@ class Project < ActiveRecord::Base
end end
def execute_services(data) def execute_services(data)
services.each do |service| services.select(&:active).each do |service|
service.async_execute(data)
# Call service hook only if it is active
begin
service.execute(data) if service.active
rescue => e
logger.error(e)
end
end end
end end
......
...@@ -82,4 +82,8 @@ class Service < ActiveRecord::Base ...@@ -82,4 +82,8 @@ class Service < ActiveRecord::Base
} }
end end
end end
def async_execute(data)
Sidekiq::Client.enqueue(ProjectServiceWorker, id, data)
end
end end
class ProjectServiceWorker
include Sidekiq::Worker
sidekiq_options queue: :project_web_hook
def perform(hook_id, data)
Service.find(hook_id).execute(data)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment