Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0d5265bb
Commit
0d5265bb
authored
Dec 07, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Execute project services asynchronously
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
2a494d99
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
8 deletions
+15
-8
app/models/project.rb
app/models/project.rb
+2
-8
app/models/service.rb
app/models/service.rb
+4
-0
app/workers/project_service_worker.rb
app/workers/project_service_worker.rb
+9
-0
No files found.
app/models/project.rb
View file @
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
...
...
app/models/service.rb
View file @
0d5265bb
...
@@ -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
app/workers/project_service_worker.rb
0 → 100644
View file @
0d5265bb
class
ProjectServiceWorker
include
Sidekiq
::
Worker
sidekiq_options
queue: :project_web_hook
def
perform
(
hook_id
,
data
)
Service
.
find
(
hook_id
).
execute
(
data
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment