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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
0f01ce36
Commit
0f01ce36
authored
Aug 21, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend pipelines queue mixin and add a default queue
parent
6509833c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
3 deletions
+25
-3
app/workers/concerns/pipeline_queue.rb
app/workers/concerns/pipeline_queue.rb
+11
-1
app/workers/pipeline_update_worker.rb
app/workers/pipeline_update_worker.rb
+2
-0
spec/workers/concerns/pipeline_queue_spec.rb
spec/workers/concerns/pipeline_queue_spec.rb
+12
-2
No files found.
app/workers/concerns/pipeline_queue.rb
View file @
0f01ce36
##
# Concern for setting Sidekiq settings for the various CI pipeline workers.
#
module
PipelineQueue
extend
ActiveSupport
::
Concern
included
do
sidekiq_options
queue: :pipeline
sidekiq_options
queue:
'pipelines-default'
end
class_methods
do
def
enqueue_in
(
queue
:,
group
:)
raise
ArgumentError
if
queue
.
empty?
||
group
.
empty?
sidekiq_options
queue:
"pipelines-
#{
queue
}
-
#{
group
}
"
end
end
end
app/workers/pipeline_update_worker.rb
View file @
0f01ce36
...
...
@@ -2,6 +2,8 @@ class PipelineUpdateWorker
include
Sidekiq
::
Worker
include
PipelineQueue
enqueue_in
queue: :pipeline
,
group: :processing
def
perform
(
pipeline_id
)
Ci
::
Pipeline
.
find_by
(
id:
pipeline_id
)
.
try
(
:update_status
)
...
...
spec/workers/concerns/pipeline_queue_spec.rb
View file @
0f01ce36
...
...
@@ -8,7 +8,17 @@ describe PipelineQueue do
end
end
it
'sets the queue name of a worker'
do
expect
(
worker
.
sidekiq_options
[
'queue'
].
to_s
).
to
eq
(
'pipeline'
)
it
'sets a default pipelines queue automatically'
do
expect
(
worker
.
sidekiq_options
[
'queue'
])
.
to
eq
'pipelines-default'
end
describe
'.enqueue_in'
do
it
'sets a custom sidekiq queue with prefix, name and group'
do
worker
.
enqueue_in
(
queue: :build
,
group: :processing
)
expect
(
worker
.
sidekiq_options
[
'queue'
])
.
to
eq
'pipelines-build-processing'
end
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