Unverified Commit 0d5265bb authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Execute project services asynchronously


Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 066e64b27a08
......@@ -390,14 +390,8 @@ def execute_hooks(data, hooks_scope = :push_hooks)
end
def execute_services(data)
services.each do |service|
# Call service hook only if it is active
begin
service.execute(data) if service.active
rescue => e
logger.error(e)
end
services.select(&:active).each do |service|
service.async_execute(data)
end
end
......
......@@ -82,4 +82,8 @@ def #{arg}=(value)
}
end
end
def async_execute(data)
Sidekiq::Client.enqueue(ProjectServiceWorker, id, data)
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